Using non Sprites with the new sorting layers

I’ve created an animated character using uni2d mesh animator, held within a game object.

How can I use this with the new sprite sorting layers, if it isn’t a new sprite object type? I want to make sure its drawn behind scenery that is a new sprite type that is tagged with foreground.

Any thoughts? Would attaching a spriterenderer component to this game object mess with it?

thanks

You can set sortingLayerName/sortingLayerID and sortingOrder properties on any Renderer via script to sort them together with Sprites.
Only the SpriteRenderer has these properties exposed via its inspector.

1 Like

I started a solution…
http://forum.unity3d.com/threads/219799-Sort-Layer-Renderer-Extension
Soon, I`ll put a better code. Please, feel free to contribute and correct some issues.

1 Like

I can’t find those properties in any documentation. Even Googling for them only brings me back to this forum. What class are they part of?
http://docs.unity3d.com/Documentation/ScriptReference/Renderer.html

They’re in the offline docs for 4.3.1 at least, in the Renderer class.

–Eric

set the sorting layer name in the Start() method and attach the script to the gameobject:

renderer.sortingLayerName = “LayerName”;
renderer.sortingOrder = 0;

1 Like