summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Scripts/DataDecoder.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Scripts/DataDecoder.cs b/Scripts/DataDecoder.cs
index b71f963..ddef18c 100644
--- a/Scripts/DataDecoder.cs
+++ b/Scripts/DataDecoder.cs
@@ -171,12 +171,23 @@ public class DataDecoder : UdonSharpBehaviour
private Color32 GetTileRGB(int tileIdx)
{
- int tileY = tileIdx * tileSize;
+ // Calculate which column and position within column this tile is in
+ int tilesPerColumn = readHeight / tileSize;
+ int column = tileIdx / tilesPerColumn;
+ int tileInColumn = tileIdx % tilesPerColumn;
+
+ // Calculate Y position (vertical position within column)
+ int tileY = tileInColumn * tileSize;
int centerY = tileY + tileSize / 2;
+ // Calculate X position (horizontal position based on column)
+ int tileX = column * tileSize;
+ int centerX = tileX + tileSize / 2;
+
if (centerY >= readHeight) return new Color32();
+ if (centerX >= readWidth) return new Color32();
- int localX = tileSize / 2;
+ int localX = centerX;
int localY = readHeight - 1 - centerY;
int index = localY * readWidth + localX;