Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to Change Depth for a compand gameOjbect in Unity2D?

Discussion in '2D' started by Deleted User, Feb 10, 2016.

  1. Deleted User

    Deleted User

    Guest

    I have a gameObject composed by a world space canvas with some images and texts.
    But since it is not a sprite, it has no order in layer.
    So I cannot change the depth of this gameObject dynamically.
    The Only way works is setting transform.z, which is really not a good approach,
    What can I do?

    PS.
    I have tried to add the sprite render component to this gameObject, though it is not a sprite.
    But the order in layer just don't work.
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    World Space Canvas has a "Sorting Layer" and "Order In Layer" property.

    Then you can control the order of the child objects of the Canvas by their actual order in the hierarchy.
     
    Last edited: Feb 10, 2016
  3. Deleted User

    Deleted User

    Guest

    It works, thank you !
     
    LiterallyJeff likes this.