| | |
| | | chunkCache.Clear(); |
| | | } |
| | | #if UNITY_EDITOR |
| | | private void OnDrawGizmos() |
| | | { |
| | | if (!Application.isPlaying) return; |
| | | //private void OnDrawGizmos() |
| | | //{ |
| | | // if (!Application.isPlaying) return; |
| | | |
| | | // Draw current chunk boundaries |
| | | if (playerTransform != null) |
| | | { |
| | | Vector2Int currentChunk = GetChunkPosition(playerTransform.position); |
| | | Gizmos.color = Color.yellow; |
| | | // // Draw current chunk boundaries |
| | | // if (playerTransform != null) |
| | | // { |
| | | // Vector2Int currentChunk = GetChunkPosition(playerTransform.position); |
| | | // Gizmos.color = Color.yellow; |
| | | |
| | | for (int x = -LOAD_DISTANCE; x <= LOAD_DISTANCE; x++) |
| | | { |
| | | for (int y = -LOAD_DISTANCE; y <= LOAD_DISTANCE; y++) |
| | | { |
| | | Vector2Int chunk = new Vector2Int(currentChunk.x + x, currentChunk.y + y); |
| | | Vector3 worldPos = new Vector3( |
| | | chunk.x * CHUNK_SIZE + transform.position.x, |
| | | chunk.y * CHUNK_SIZE + transform.position.y, |
| | | 0 |
| | | ); |
| | | // for (int x = -LOAD_DISTANCE; x <= LOAD_DISTANCE; x++) |
| | | // { |
| | | // for (int y = -LOAD_DISTANCE; y <= LOAD_DISTANCE; y++) |
| | | // { |
| | | // Vector2Int chunk = new Vector2Int(currentChunk.x + x, currentChunk.y + y); |
| | | // Vector3 worldPos = new Vector3( |
| | | // chunk.x * CHUNK_SIZE + transform.position.x, |
| | | // chunk.y * CHUNK_SIZE + transform.position.y, |
| | | // 0 |
| | | // ); |
| | | |
| | | // Draw chunk boundary |
| | | Gizmos.DrawWireCube( |
| | | worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | new Vector3(CHUNK_SIZE, CHUNK_SIZE, 0) |
| | | ); |
| | | // // Draw chunk boundary |
| | | // Gizmos.DrawWireCube( |
| | | // worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | // new Vector3(CHUNK_SIZE, CHUNK_SIZE, 0) |
| | | // ); |
| | | |
| | | // Draw chunk coordinates |
| | | UnityEditor.Handles.Label( |
| | | worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | $"({chunk.x}, {chunk.y})" |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // // Draw chunk coordinates |
| | | // UnityEditor.Handles.Label( |
| | | // worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | // $"({chunk.x}, {chunk.y})" |
| | | // ); |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | #endif |
| | | } |