Version: 2023.2
言語: 日本語
public Vector3Int LocalToCell (Vector3 localPosition);

パラメーター

localPosition Local Position to convert.

戻り値

Vector3Int Cell position of the local position.

説明

Converts a local position to cell position.

// 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); } }