- Home /
Question by
Reign_of_Light · Oct 14, 2014 at 07:58 PM ·
layerssorting layers
How to rearrange sorting layers via script?
Hi,
I know you can access and change the order of sprites within a sorting layer via gameobject.renderer.sortingOrder . But is there a scripting way to change the order of the sorting layers themselves? In the Unity editor you can manually change the order of the sorting layers by means of dragging & dropping in the 'Edit'->'Project Settings'->'Tags and Layers'-Panel. But is there a way to do it with script?
Best regards
Comment
Answer by slader155 · Feb 04, 2015 at 07:40 AM
Use Renderer.sortingOrder. So for example if you were changing the sorting order of the player it would be: player.GetComponent().sortingOrder = 1
(for example);
Hope this helps! :D