Render order and SetSiblingIndex

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.

1 Like

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.

1 Like

Many thanks