I have a terrain generating procedure that takes 30-60 seconds to run every time it’s called and works to my satisfaction. I might be able to optimize it a bit so it doesn’t take quite as long but will still take several seconds to run. (The procedure has several nested loops.)
I want to display a “loading…” screen so the user doesn’t think the game crashed. I understand how to use coroutines but it seems like I will have to create several methods that perform specific steps of the procedure and have the coroutine constantly check their status until they’re finished.
Any ideas on the best way to do this?
(Let me know if my explanation needs clarification.)
If it only takes several seconds, you can just do some simple animation that is not related to the real progress of generation i.e. loading bar in windows, or loading texts with dots.
Than if it goes longer than that, you can distract user by showing the actual activity, like they do in Sir you are being hunted, or minecraft (i.e. generating north clusters etc, which will be displayed on entering to each of your loops). You also can print out time.time of finishing each of your loops (in editor), and assign them estimate progress (like 20%, 50%) than display it on the screen along with the info what the game is doing right now. This should calm the user.
Finally you can estimate more precisely how much does each step take from overall loading time, each iteration of each inner loop and show the more precise progress based on that. Or you can count the outcome (number of triangles etc… in the generated scene in the scene (in editor mode)), and than calculate percentage on run via currently generated/maximum counter. This is however complicated, and user does not need to know it exactly.
One advice I’ve seen a lot, is to put a “Hint of a day” field on the loading screen (.i.e you can get better loot from higher level enemies etc…) this always takes users mind of the loading time. I’ve seen somewhere multiple hint changing each 5 secs or so.
Hope it will give you the idea !
For those interested, here is a link to the solution I’m using until I get Unity Pro…