flo-wolf / Flip-Fall

Flip Fall - Mobile Arcade Platformer, made with Unity. Available on the Play Store
https://play.google.com/store/apps/details?id=com.florianwolf.flipfall
Other
21 stars 4 forks source link

Preload Scenes before switching to reduce Background stutter #61

Closed flo-wolf closed 7 years ago

flo-wolf commented 8 years ago

http://answers.unity3d.com/questions/274122/load-scene-without-lag.html

MeikelLP commented 7 years ago

Depricated! Use Unity 5 tools instead: SceneManager.LoadSceneAsync

flo-wolf commented 7 years ago

Anticipated result was not achieved through async scene loading. Apparently the hiccups get caused by Start() and Awake() calls of all newly added GameObjects upon scene change. Proper scheduling of those calls through coroutines might fix it, although the implementation of such Monobehaviour extensions might be complicated and possibly not possible due to Unity's script protection.

MeikelLP commented 7 years ago

You can make Start() and Awake() to IEnumerators so unity calls the with a couroutine. Maybe the Start() and Awake() function have too big complexity and needs to be outsourced as well?

flo-wolf commented 7 years ago

Even with Start and Awake IEnumerations the lag will still be there, the calls only get delayed/put on another thread, but they nonetheless draw performance.

I've managed to reduce the lag by quite a big portion through moving complex iterations and resource intensive calls to the start of the game, from where the gathered data gets stored throughout scene changes. The data itself is not memory intensive, which is why this is the best possible solution.

MeikelLP commented 7 years ago

User Coroutines and load your stuff asynchronously. Load assets async is lag free if you do it correctly.

flo-wolf commented 7 years ago

Tried it, it isnt.

MeikelLP commented 7 years ago

So you did not do it correctly. There are games out there which have no lagging loading screens build with Unity 4

flo-wolf commented 7 years ago

Try it yourself then

MeikelLP commented 7 years ago

I did. My loading screen loads every Asset I have (~40MB) and instantiates it to be sure it is loaded. No lag. Some assets take longer but the loading indicator (spinning gear) is still rotating.