Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using non Sprites with the new sorting layers

Discussion in '2D' started by Deleted User, Nov 18, 2013.

  1. Deleted User

    Deleted User

    Guest

    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
     
  2. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    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.
     
    rakkarage likes this.
  3. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    Wooziziz likes this.
  4. Ferb

    Ferb

    Joined:
    Jan 4, 2014
    Posts:
    25
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They're in the offline docs for 4.3.1 at least, in the Renderer class.

    --Eric
     
  6. BlackPanda

    BlackPanda

    Joined:
    Jan 24, 2014
    Posts:
    78
    set the sorting layer name in the Start() method and attach the script to the gameobject:

    renderer.sortingLayerName = "LayerName";
    renderer.sortingOrder = 0;
     
    tomandresen likes this.