Пример #1
0
    void OnDrawGizmos()
    {
        if (grid == null)
        {
            DebugExtension.DebugLocalCube(transform, new Vector3(1, 1, 1));
        }
        else if (drawGrid)
        {
            Vector3 cellExtent = grid.GetCellExtent();
            Vector3 gridExtent = grid.GetExtent();
            Vector3 numCells   = new Vector3(grid.GetNumCells(0), grid.GetNumCells(1), grid.GetNumCells(2));
            Vector3 gridOrigin = grid.GetMinCorner();

            for (int i = 0; i < numCells.x; ++i)
            {
                for (int j = 0; j < numCells.y; ++j)
                {
                    for (int k = 0; k < numCells.z; ++k)
                    {
                        Gizmos.color = new Vector4(0.7f, 0.7f, 1, 0.2f);
                        Gizmos.DrawWireCube(gridOrigin + new Vector3(cellExtent.x * i + cellExtent.x / 2, cellExtent.y * j + cellExtent.y / 2, cellExtent.z * k + cellExtent.z / 2), cellExtent);
                    }
                }
            }
        }
    }