Example #1
0
        public void SetLocalId(int x, int y, int z, int id)
        {
            if (y < 0 || y > height - 1 || x < 0 || x > size - 1 || z < 0 || z > size - 1)
            {
                return;
            }

            map[x, y, z] = id;
            if (initialized)
            {
                StartCoroutine(BuildMesh());
            }

            Chunk chunk = null;

            if (x == 0)
            {
                chunk = Find(new Vector3(x - 1, y, z) + transform.position);
            }
            else if (x == size - 1)
            {
                chunk = Find(new Vector3(x + 1, y, z) + transform.position);
            }
            if (chunk != null && chunk.initialized)
            {
                StartCoroutine(chunk.BuildMesh());
            }

            if (z == 0)
            {
                chunk = Find(new Vector3(x, y, z - 1) + transform.position);
            }
            else if (z == size - 1)
            {
                chunk = Find(new Vector3(x, y, z + 1) + transform.position);
            }
            if (chunk != null && chunk.initialized)
            {
                StartCoroutine(chunk.BuildMesh());
            }
        }