From 9ca4a339698dba58baf82ff8daaf9d8de5026676 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Thu, 03 Apr 2025 21:02:34 +0000
Subject: [PATCH] show chunk position in gizmo
---
Assets/Scripts/GenerateTileMap.cs | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Assets/Scripts/GenerateTileMap.cs b/Assets/Scripts/GenerateTileMap.cs
index 7bf0667..c102143 100644
--- a/Assets/Scripts/GenerateTileMap.cs
+++ b/Assets/Scripts/GenerateTileMap.cs
@@ -124,7 +124,7 @@
private void UnloadChunk(Vector2Int chunk)
{
int startX = chunk.x * CHUNK_SIZE;
- int startY = chunk.y * CHUNK_SIZE;
+ int startY = (chunk.y * CHUNK_SIZE)-1;
for (int x = startX; x < startX + CHUNK_SIZE; x++)
{
@@ -232,7 +232,7 @@
private IEnumerator GenerateChunk(Vector2Int chunk, List<Vector3Int> destroyedTiles)
{
int startX = chunk.x * CHUNK_SIZE;
- int startY = (chunk.y * CHUNK_SIZE);
+ int startY = (chunk.y * CHUNK_SIZE)-1;
// Generate ground in chunk
for (int x = startX; x < startX + CHUNK_SIZE; x++)
@@ -473,10 +473,17 @@
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})"
+ );
}
}
}
--
Gitblit v1.10.0