Game build crashes when loading new scene but not in the Editor
Hi, I have a problem where I have built a unity project with a menu and a game scene. In the game scene, I have an object with a script on it that procedurally generates terrain. In the built version of the game, if I load the game scene and then move back to the menu, once I enter the game scene again, during the load, the game will freeze and then crash. I traced the problem back to the terrain object. I thought it might be the DontDestroyOnLoad object that was causing this but all that it did was generate a Debug script of some kind.
I built the game into a Development version of it and the last paragraph of the Player.log before unity crash, says:
(Filename: C:/Users/isaac/Desktop/NerdIt/Geometria/Geometria/Geometria 2.0/GeometriaHDRP/Assets/Script/LoadingMech.cs Line: 20)
UnloadTime: 0.497700 ms
OutOfMemoryException: Out of memory
at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
at System.Collections.Generic.List`1[T].set_Capacity (System.Int32 value) [0x00021] in <c79628fadf574d3a8feae0871fad28ef>:0
at System.Collections.Generic.List`1[T].EnsureCapacity (System.Int32 min) [0x00036] in <c79628fadf574d3a8feae0871fad28ef>:0
at System.Collections.Generic.List`1[T].Add (T item) [0x00010] in <c79628fadf574d3a8feae0871fad28ef>:0
at MarchingCubes.March (System.Single x, System.Single y, System.Single z, System.Single[] cube, System.Collections.Generic.IList`1[T] vertList, System.Collections.Generic.IList`1[T] indexList) [0x001b0] in C:\Users\isaac\Desktop\NerdIt\Geometria\Geometria\Geometria 2.0\GeometriaHDRP\Assets\MeshTech\MarchingCubes.cs:61
at Marching.Generate (System.Collections.Generic.IList`1[T] voxels, System.Int32 width, System.Int32 height, System.Int32 depth, System.Collections.Generic.IList`1[T] verts, System.Collections.Generic.IList`1[T] indices) [0x000c5] in C:\Users\isaac\Desktop\NerdIt\Geometria\Geometria\Geometria 2.0\GeometriaHDRP\Assets\MeshTech\Marching.cs:62
at Grids.DrawMesh () [0x0006f] in C:\Users\isaac\Desktop\NerdIt\Geometria\Geometria\Geometria 2.0\GeometriaHDRP\Assets\Script\Grids.cs:112
at Grids.Start () [0x0006d] in C:\Users\isaac\Desktop\NerdIt\Geometria\Geometria\Geometria 2.0\GeometriaHDRP\Assets\Script\Grids.cs:36
(Filename: <c79628fadf574d3a8feae0871fad28ef> Line: 0)
System memory in use before: 504.9 MB.
System memory in use after: 432.9 MB.
Unloading 30 unused Assets to reduce memory usage. Loaded Objects now: 2402.
Total: 486.089200 ms (FindLiveObjects: 0.196200 ms CreateObjectMapping: 0.049000 ms MarkObjects: 479.696500 ms DeleteObjects: 6.147100 ms)
I have no idea what any of that means. I assume it is something to do with one of my mesh generation scripts, but I don't know which one. So I am going to post the link to the project download.
I really need help with this. If I can't figure this out I am going to have to force the player to restart the game every time they want to re-start up the scene. I am desperate.
Project Assets: https://drive.google.com/file/d/1_46uJYcW5arDRO-3TZBQob69Vt7JxaHd/view?usp=sharing
Your answer
Follow this Question
Related Questions
My project doesn't open as Unity stops responding 1 Answer
Loading game data crashes on android 0 Answers
Build Crashes on Startup 1 Answer
CommandInvokationFailure when building for Android 1 Answer
Can't build android application 1 Answer