Search Unity

SetSiblingIndex VERY slow since 5.4

Discussion in 'UGUI & TextMesh Pro' started by Cripple, Sep 9, 2016.

  1. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Hi,

    We just moved from 5.3 to 5.4, and we noticed a major issue with the SetSiblingIndex function on RectTransform which is mandatory in order to control the draw order of our UI elements at runtime.

    We have an overlay UI which fakes a WorldUI because we want to keep fixed sized elements. We need to sort them when the user moves the camera, thats why we use SetSiblingIndex almost every frame.

    On a good computer, it takes 1ms per Object moved, when we have 50 plus elements, it is just unthinkable.

    CAN you please expose a DrawOrder property on Graphics like in Canvas and don't rely on Hierarchy Order, that is just too expensive, or at least fix it.
     
    Last edited: Sep 12, 2016
  2. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    I just ran into the same problem trying to do the exact same thing (in Unity 5.5). Did you find any solution to it?
     
  3. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
  4. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    Very interesting talk, thanks! Although I'm not sure if this also significantly affects the performance of changing sibling order... seems to mostly affect reparenting.

    In any case, at least for me the problem didn't turn out to be the calls to SetSiblingIndex itself. The problem was caused by having a CanvasGroup component further up in the hierarchy. Without the CanvasGroup the SetSiblingIndex calls are fast (reported as #868226 just in case a Unity dev stumbles across this thread).
     
    phil-Unity likes this.