public static GameObject PositionToChunk(Vector3 position) { Index chunkIndex = new Index(Mathf.RoundToInt(position.x / Engine.ChunkScale.x) / Engine.ChunkSideLength, Mathf.RoundToInt(position.y / Engine.ChunkScale.y) / Engine.ChunkSideLength, Mathf.RoundToInt(position.z / Engine.ChunkScale.z) / Engine.ChunkSideLength); return(ChunkManager.GetChunk(chunkIndex)); }
public static GameObject SpawnChunk(Index index) { GameObject chunk = ChunkManager.GetChunk(index); if (chunk == null) { return(Engine.ChunkManagerInstance.DoSpawnChunk(index)); } else { return(chunk); } }
// ==== 延申chunk们 ==== public static GameObject SpawnChunk(int x, int y, int z) { // spawn一个单独的chunk GameObject chunk = ChunkManager.GetChunk(x, y, z); if (chunk == null) { return(Engine.ChunkManagerInstance.DoSpawnChunk(new Index(x, y, z))); } else { return(chunk); } }