void Awake() { chunkMeshFilter = gameObject.GetComponent <MeshFilter>(); chunkMeshRenderer = GetComponent <MeshRenderer>(); chunkMeshCollider = gameObject.GetComponent <MeshCollider>(); chunkMeshFilter.mesh = chunkMesh = new Mesh(); chunkMeshCollider.sharedMesh = chunkMesh; chunkMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; ChunkBounds = new Bounds(ChunkPosition, ChunkSize); WorldChunks.Add(ChunkVectors.CreateChunkIndex(ChunkPosition), this); ChunkIndex = ChunkVectors.CreateChunkIndex(ChunkPosition); }
void OnDestroy() { WorldChunks.Remove(ChunkVectors.CreateChunkIndex(ChunkPosition)); }