Search Unity

2017.3.0f1 RectTransform is not updated if object is not active?

Discussion in 'UGUI & TextMesh Pro' started by sama-van, Dec 27, 2017.

  1. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    My UI build perfectly in 2017.2.x.

    Below a code sample from a loop making a list of buttons :

    Code (csharp):
    1.  
    2.                     GameObject go = Instantiate (goBtnTemplate) as GameObject;
    3.                     go.name = "btn_Tool-" + tool;
    4.                     RectTransform rect = go.GetComponent<RectTransform> ();
    5.                     rect.SetParent (goRootTools.transform);
    6.                     rect.localScale = Vector3.one;
    7.                     rect.localPosition = new Vector3 (i * width, 0, 0);
    8.  
    9.                     go.SetActive (true);
    10.  
    Every other UI also made dynamically doesn't update the position of any RectTransform.

    I doesn't work in 2017.3, the edition of the rect.localPosition and rect.position has no effect at all.

    The code has been writing since last September then no problem at all from every single Unity version before 2017.3.

    Does anyone experienced similar issue?
    Any tips? fix?

    Thank you! :)
     
  2. Wentz

    Wentz

    Joined:
    Dec 18, 2016
    Posts:
    2
    I had pretty much the same issue but i was setting localPosition. I changed it from localPosition to anchoredPosition and it worked as it did before.
     
    sama-van likes this.
  3. AIVIK

    AIVIK

    Joined:
    Feb 12, 2015
    Posts:
    14
  4. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    @Wentz
    anchoredPosition3D is working a charm!
    Thank you so much! :)