Параметры
cellPosition | Позиция ячейки для преобразования. |
Возвращает
Vector3 Мировая позиция позиции ячейки.
Описание
Преобразует позицию ячейки в мировую позицию в пространстве.
// Snap the GameObject to parent GridLayout
using UnityEngine;
public class ExampleClass : MonoBehaviour
{
void Start()
{
GridLayout gridLayout = transform.parent.GetComponentInParent<GridLayout>();
Vector3Int cellPosition = gridLayout.WorldToCell(transform.position);
transform.position = gridLayout.CellToWorld(cellPosition);
}
}