I have set up a procedural level generation script that creates a bunch of complex meshes and then converts them into render textures for use as sprites. It also instantiates some other objects. In order to regenerate a level, I reload the scene (asynchronously).
However, on loading/generating the scene, whether directly after pressing play or after moving onto the next level, it seems Unity has a chance of crashing (about 1/5). None of this seems to be an issue in build (for the small time tested).
I have tried:
- Converting function to coroutine and adding short delay between each heavy processing
- Looking at crash logs but they are unhelpful - they just say Crash!! after running the generate function
- Checking for recursion (although this usually freezes up rather than directly crashes) - there are no while loops in code, and I’m pretty sure the for loops are purely iterative.
I am unaware if it corresponds to the seed given.
Any ideas on what could be causing these infuriating crashes?
Here is the crashlog, please let me know if you would like to see any code snippets (the whole level gen script is really long).
Loaded scene 'Temp/Backupscenes/0.backup'
Deserialize: 6.583 ms
Integration: 72.009 ms
Integration of assets: 0.007 ms
Thread Wait Time: 0.005 ms
Total Operation Time: 78.603 ms
Unloading 9 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 2.769800 ms
Loaded scene 'Temp/Backupscenes/0.backup'
Deserialize: 3.084 ms
Integration: 34.254 ms
Integration of assets: 0.002 ms
Thread Wait Time: 5.835 ms
Total Operation Time: 43.175 ms
Crash!!!