This problem has been buggering be for quite some while. I have found a solution, bet it’s not as clean as i’d want.
Here are examples.
private void Start() {
GameObject node = (GameObject)Instantiate(contentPrefab);
RectTransform rectComponent = node.GetComponent<RectTransform>();
Debug.Log(rectComponent.sizeDelta.y.ToString()); //prints 0 ?
}
private IEnumerator Start() {
GameObject node = (GameObject)Instantiate(contentPrefab);
RectTransform rectComponent = node.GetComponent<RectTransform>();
yield return new WaitForSeconds(0.1f); //wait for some small time
Debug.Log(rectComponent.sizeDelta.y.ToString()); //prints actual value, not 0
}
Looks like UI elements are not updated on instantiation, but in fact left for update on next iterations.
Has anyone tried any workarounds, without using any update methods?