void OnDestroy() { if (lodDataUpdate != null) { lodDataUpdate.Stop(); } Debug.Log("Mem size before vfTerrain destroyed all chunks :" + GC.GetTotalMemory(true)); if (gameObject.transform.childCount > 0) { // Clean up chunks for (int i = gameObject.transform.childCount - 1; i >= 0; --i) { var child = gameObject.transform.GetChild(i).gameObject; DestroyImmediate(child); } } }
void OnDestroy() { if (_lodDataUpdate != null) { _lodDataUpdate.Stop(); _lodDataUpdate = null; } if (_transGoCreator != null) { _transGoCreator.IsTransvoxelEnabled = false; _transGoCreator = null; } if (SurfExtractor != null) { SurfExtractor.Reset(); } if (_dataLoader != null) { _dataLoader.Close(); } // If something is left over... (in the editor) if (gameObject.transform.childCount > 0) { // Clean up chunks for (int i = gameObject.transform.childCount - 1; i >= 0; --i) { var child = gameObject.transform.GetChild(i).gameObject; DestroyImmediate(child); } } Resources.UnloadUnusedAssets(); TerrainVoxelComplete = false; TerrainColliderComplete = false; bChunkColliderRebuilding = true; self = null; VFVoxelSave.Clean(); }