Sorry if this is a common problem, but I have some code that’s trying to access the height of a text box (childed in a GameObject) right after instantiating it, and for some reason it’s returning 0. I suspect this is because of something about instantiate() that I don’t know, or because it’s nested in a foreach(). It works fine for all of the boxes that haven’t been instantiated this frame, but not the newest one. Thanks for the help! Here’s a sample of the code:
Where the height is accessed (in adjustheights()):
...
float checkHeight = 0f;
foreach (GameObject x in handledBoxes) {
checkHeight += x.GetComponentInChildren<RectTransform>().rect.height;
//ALWAYS RETURNS 0 FOR THE HEIGHT OF THE MOST RECENTLY INSTANTIATED BOX
...
}
Fantastic! Thank you so much - it’s a Merry Coding Christmas after all! I had to insert ForceUpdateCanvases() after the instantiate line instead of in a Start(), but once I made that little change it worked like a charm. Thank you again!!!