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

Render order and SetSiblingIndex

Discussion in 'UGUI & TextMesh Pro' started by andsee, Aug 21, 2014.

  1. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    I like the fact that the UI system uses the transform child order to define the rendering order. I've just come across a situation where I need to change this programatically and have a question about how intelligent SetSiblingIndex on a transform is.

    Basically will it quickly return if I set it to the index that it already holds avoiding any changes and associated performance hit.

    Or should I call GetSibilingIndex first and compare (this could be worse depending on wether GetSibilingIndex just returns a cached value or calculates the index)

    Or do I need to track the index, which has the possibility of issues/ becoming out of sync as I assume if I move a hierarchy from say index 5 to index 2 the transforms that were 2 - 4 would become 3 - 5.
     
    rakkarage likes this.
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,194
    Currently we don't do any checking, I've pinged the developer responsible to check before we call set so we can avoid the extra processing.
     
    rakkarage likes this.
  3. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    Many thanks