I stumbled accross I cuirous problem. Right now I have the following setup.
I have a Gameobject with a UITexture. The Gameobject is disabled in the editor, so Start() and all the others only start when I activate the gameobject during runtime.
This is what I do in my code:
uitexture.gameObject.SetActive(true);
panel.Refresh();
What I wanted to do is to activate the UITexture and then refresh it's panel, so that the texture is visible in the same frame. After some research I discovered that the UITexture gets added to the panel after I refresh the panel. This happens because the UIRect.Start is called after the panel refresh. I already tried setting up the Script Execution Order so that the panel is always after the UIRect, but that didn't work.
The obvious solution would be something like this:
uitexture.gameObject.SetActive(true);
uitexture.Start();
panel.Refresh();
But this could lead to other problems like widgets added multiple times to a panel. So now I'm wondering what would be the best way to ensure that a UIRect is initialized before calling a corresponding UIPanel.Refresh().
Thanks in advance