This version of Unity is unsupported.

GridLayout.CellToLocal

Declaration

public Vector3 CellToLocal(Vector3Int cellPosition);

Parameters

cellPosition Cell position to convert.

Returns

Vector3 Local position of the cell position.

Description

Converts a cell position to local position space.

// Snap the GameObject to parent GridLayout
using UnityEngine;

public class ExampleClass : MonoBehaviour { void Start() { GridLayout gridLayout = transform.parent.GetComponent<GridLayout>(); Vector3Int cellPosition = gridLayout.LocalToCell(transform.localPosition); transform.localPosition = gridLayout.CellToLocal(cellPosition); } }