Hello there,
I just started developping on unity a few weeks ago, and learned on my own, so i may have misunderstood some mechanisms or behaviours. If so, my apology for the question i’m going to ask.
I’m actually developping a mobile game that need to frequently generate random levels as the player progress through it, so as it is now, i’m loading these levels stored as prefabs in the Resource directory of my project. I also possess a script attached to an empty object on the scene who will be in charge of loading and handling the levels generated. It works by making dynamically(as the object is instantiated) a 2Darray of the hierarchy of files where i stored my level prefabs, which will later on let me load my levels using Instantiate(Resources.Load()).
As i am aware that resource folder contents are stored into a resources.asset file on iPhone stored who knows where, i used Resources.LoadAll() for each of my level directories for listing them into my array to avoid too much path issues.
Everything works well on computer, but as soon as i pass on mobile, the game takes an insane amount of time to load the scene, also even though i used coroutines(which is supposed to simulate some threading behaviour if i did understand it right) for loading levels while the player is still actively playing, there is still some freezes each time the game has to load another level.
So, i read on multiple topics that i should be using Resources.Load/LoadAll everytime i need to access some assets, but right now it’s making me have a LOT of loading time.
I’ve checked on the profiler too, the only time where my cpu is spiking is when i need to load these levels themselves.
I would like to know if i made some conception errors, or if i misunderstood something while learning to code on Unity, and also if somebody knows some tips or ways to reduce to the utmost the resource loading time?
If a similar thread was posted before, please link it to me too, as i may have overlooked some links in my researchs too, though i’ve been looking for an answer for a few days now…
Thank you in advance for your time.