|
Post by chemari on Nov 16, 2022 12:40:18 GMT
Hi! In our game we have several UI screens. To optimize the loading time in some cases we preload the next UI screens in the background (they remain inactive until needed).
So in some cases where we are trying to populate an enhanced scroller in an inactive screen, this causes the ReloadData to be called before the EnhancedScroller Awake, thus causing an exception, as many fields are not even initialized.
We find a temporary fix consisting in adding a coroutine to delay 1 frame the ReloadData call. But I was wondering anyway if there is a proper way to populate an EnhancedScroller object without waiting the parent to be rendered.
Thanks for the support! this tool is helping us a lot.
|
|
|
Post by echo17 on Nov 17, 2022 13:54:03 GMT
That's a good question. The Awake method caches a lot of components to speed up processing later (instead of trying to find them each time a method is called). You might be able to move all the code in Awake to a public method, then call that method from another script. You'd have to also call that method from the Awake for other scrollers that don't need to be preloaded.
I'm not positive this will work since I don't know how Unity sees gameobjects before a component has called its Awake method.
|
|