using System.Collections; using System.Collections.Generic; using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif public class BlockMap : MonoBehaviour { public int[] data; public int xSize = 3; public int ySize = 3; public int zSize = 3; private void Start() { if (data.Length != xSize * ySize * zSize) data = new int[xSize * ySize * zSize]; } public int this[int x, int y, int z] { get { int index = 0; index += z * (ySize * xSize); index += y * xSize; index += x; return data[index]; } set { int index = 0; index += z * (ySize * xSize); index += y * xSize; index += x; data[index] = value; } } #if UNITY_EDITOR private void OnDrawGizmos() { if (!Application.isPlaying) return; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { for (int z = 0; z < zSize; z++) { Handles.Label(new Vector3(x, y, z), this[x, y, z].ToString()); } } } } #endif }