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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Vertical Layout not updating with SetSiblingIndex

Discussion in 'UGUI & TextMesh Pro' started by 777mike777, Feb 7, 2015.

  1. 777mike777

    777mike777

    Joined:
    Jan 26, 2015
    Posts:
    6
    Hi
    For some reason when I use SetSiblingIndex to change the order of objects at runtime
    the objects change order in the hierarchy but not in the game window.
    The objects parent has a Vertical Layout Script so it should update the order.
    Any ideas why this doesn't work?
    Thank you
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    Just tested with a scene in 4.6.1.
    I used:
    GO (with Vert or Hor layout Grout)
    4 Children images each different colours
    1 Button, with an event pointing at one of the Images SetSiblingIndex method

    In runtime however, it works fine. Setting the SiblingIndex in script works fine. Tested using both Horizontal and Vertical layouts without issue.

    There is a CalculateLayoutInputHorizontal method on all layout groups to reorder children each frame.

    So not sure what your issue is, unless it is a bug introduced in a later release.
     
  3. 777mike777

    777mike777

    Joined:
    Jan 26, 2015
    Posts:
    6
    Thanks for replying
    When I disable and enable the vertLayoutGroupScript in the hierarchy (while playing) it reorders the ui panels
    I tried adding CalculateLayoutInputVertical after using SetSiblingIndex but it doesn't work.
     
  4. POiD

    POiD

    Joined:
    Dec 18, 2013
    Posts:
    4
    Check the Scale of your objects. The scale on my prefabs was 1,1,1 but the scale on my instantiated prefabs was set to 0,0,0. I'm assuming this was because I was pre-loading objects, while the Canvas was not enabled.

    Adding code to set the Scale back sorted my issue.