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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Can one sort UI depth programatically?

Discussion in 'UGUI & TextMesh Pro' started by AtticusMarkane, Sep 2, 2014.

  1. AtticusMarkane

    AtticusMarkane

    Joined:
    Aug 6, 2014
    Posts:
    18
    I have started trying out uGUI in a prototype project and have come across a bit of a roadblock: Is there a way to sort UI elements within an overlay canvas at runtime (programatically)?

    Alternatively I think I could use a dedicated UI camera, camera canvas and the z value to achieve sorting capabilities in an overlay, but I would prefer it if the overlay canvas could handle all of this.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,749
    The magic words in the documentation you're looking for are "sibling index" under the Transform class. Those functions are equivalent to dragging the transform order around in the hierarchy.
     
  3. AtticusMarkane

    AtticusMarkane

    Joined:
    Aug 6, 2014
    Posts:
    18
    Thanks for the help, I found the documentation and I'm going to give it a try. I never would have stumbled upon sibling index on my own, much appreciated.