Game Development Reference
In-Depth Information
}
}
Here, the script simply sets the sorting layer on the underlying renderer for the particle
system; in this case, I've hardcoded it to the GUI sprite layer.
Note
The [ExecuteinEditMode] attribute just enables you to see the effect in the editor as
well. More on editor functionality is covered in Chapter 11 , Onward Wary Traveler .
Script libraries, such as the awesome UnityToolbag by Nick Gravelyn, also provide the
previous functionality and are worked into a more reusable script; it's well worth checking
it out at https://github.com/nickgravelyn/UnityToolbag .
Tip
Another one of these libraries will also expose the hidden SortingLayer properties for
3D renderers in the editor. For more information, you can read about it at ht-
tps://github.com/nickgravelyn/UnityToolbag/tree/master/SortingLayer .
Now just attach this script to the particle system and it will be transformed into what is
shown in the following screenshot, with the particles now in front of the background:
Search WWH ::




Custom Search