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

UI button positions incorrect if canvas.SetActive(false);

Discussion in 'UGUI & TextMesh Pro' started by GMagnetic, Oct 11, 2015.

  1. GMagnetic

    GMagnetic

    Joined:
    Dec 8, 2014
    Posts:
    23
    We use a different canvas for portrait and landscape on iOS devices to tightly control button placement.

    We use SetActive() to hide/show the right canvas when orientation change is detected.

    We also have functionality that "slides" some buttons from one position to another.

    If you change the device orientation at least once before invoking the slide functionality all is well.

    However if you are in portrait and invoke the slide functionality and you the rotate to landscape all the controls that should have slid to their new positions have gathered at the anchor point, it seems all the x,y,z coords are zero.

    Is there a work around for this?
     
  2. GMagnetic

    GMagnetic

    Joined:
    Dec 8, 2014
    Posts:
    23
    Ahhh, got it, needed to use localPosition, looks like position factors in parent coords which would appear to be 0,0,0 when canvas.SetActive(false);