void OnDestroy() { if (SourceIndex != -1) { Terrains.RemoveAt(SourceIndex); UnusedIndexes.Add(SourceIndex); Terrains.Insert(SourceIndex, GameTools.CreateEmptySource()); NavMeshRegion.StartManualUpdate = true; //Debug.Log("Destroyed: " + SourceIndex); } }
void OnEnable() { TheMeshFilter = GetComponent <MeshFilter>(); TheTerrain = GetComponent <Terrain>(); TheCollider = GetComponent <Collider>(); if (!HasGeneratedDummySource) { Terrains.Add(GameTools.CreateEmptySource()); HasGeneratedDummySource = true; } Collect(); }