How to modify RectTransform properties in script [Unity 4.6 beta]

后端 未结 7 936
面向向阳花
面向向阳花 2020-12-24 15:03

\"enter

Hello, I\'m using the new UI system from Unity 4.6 beta...

Tried diffe

7条回答
  •  情书的邮戳
    2020-12-24 15:29

    When changing parent (eg after Instantiate), things get messy, I found resetting a few parameters really helped (spent quite a bit of time trying to figure this out):

    this.transform.SetParent(content.transform);
    this.transform.localScale = Vector3.one;            
    this.rectTransform.sizeDelta = Vector2.zero;
    this.rectTransform.anchoredPosition = Vector2.zero;
    

    Hope that helps someone else :)

提交回复
热议问题