Reputation: 65
Working on a Unity3d-project, we are having an issue that we can't solve: We use a GridLayoutGroup with several children to provide a Drag'n'Drop-System. Therefore we have one GridLayoutGroup fixed in the scene and one panel width a dynamically created amount of children via script.
If we execute the script by command in another script, everything works fine and all the slots are visible and working. But if the script is executed automatically by OnLevelWasLoaded, the slots are created in the right position, but not visible. Even if the background and everything else is disabled, we can not see the slots.
I hope, you have a possible solution for our problem :)
Upvotes: 1
Views: 678
Reputation: 868
I think the problem is that OnLevelWasLoaded()
fires before Awake()
and you're trying to instantiate your prefabs when none of the UI components are initialized (most of the time this happens in Awake()
). I recommend to move your code from OnLevelWasLoaded()
to OnEnable()
(for example) or to any other MonoBehaviour event that would satisfy your needs.
Upvotes: 1