# GetCellPoints()

> Gets the points which outline a cell of the GridLayout.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/7000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.GridModule

```csharp
public ReadOnlySpan<Vector3> GetCellPoints()
```

### Returns

| Type                                                                                   | Description                                     |
| -------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [ReadOnlySpan\<Vector3>](https://learn.microsoft.com/dotnet/api/system.readonlyspan-1) | The points which outline a cell, in cell space. |

### Remarks

The points are in cell space, so they describe a cell before [GridLayout.cellSize](/engine/7000.0/script-reference/unityengine/gridlayout/cellsize.md) is applied. Scale them by [GridLayout.cellSize](/engine/7000.0/script-reference/unityengine/gridlayout/cellsize.md) for the shape of a cell, then [Grid.Swizzle](/engine/7000.0/script-reference/unityengine/grid/swizzle.md) that by [Grid.cellSwizzle](/engine/7000.0/script-reference/unityengine/grid/cellswizzle.md) and offset it by [GridLayout.CellToLocal](/engine/7000.0/script-reference/unityengine/gridlayout/celltolocal.md) to place it on a given cell. They trace the cell's outline clockwise, so consecutive points are the cell's edges. The same points serve every cell of the [GridLayout](/engine/7000.0/script-reference/unityengine/gridlayout.md), so they are read straight from the engine and nothing is copied or allocated.

### Examples

```csharp
 // Draw the outline of the cell at the origin
using System;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    void OnDrawGizmos()
    {
        Grid grid = GetComponent<Grid>();
        ReadOnlySpan<Vector3> points = grid.GetCellPoints();
        Vector3 origin = grid.CellToLocal(Vector3Int.zero);
        for (int i = 0; i < points.Length; ++i)
        {
            Vector3 from = origin + Grid.Swizzle(grid.cellSwizzle, Vector3.Scale(points[i], grid.cellSize));
            Vector3 to = origin + Grid.Swizzle(grid.cellSwizzle, Vector3.Scale(points[(i + 1) % points.Length], grid.cellSize));
            Gizmos.DrawLine(grid.LocalToWorld(from), grid.LocalToWorld(to));
        }
    }
}
```
