기술 자료

Unity Engine

Unity Engine

CellToLocal(Vector3Int)

Converts a cell position to local position space.
읽는 시간 1분최근 업데이트: 한 달 전

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.GridModule
public Vector3 CellToLocal(Vector3Int cellPosition)

Parameters

cellPosition

Cell position to convert.

Returns

Type

Description

Vector3Local position of the cell position.

Examples

// Snap the GameObject to parent GridLayoutusing UnityEngine;public class ExampleClass : MonoBehaviour{ void Start() { GridLayout gridLayout = transform.parent.GetComponent<GridLayout>(); Vector3Int cellPosition = gridLayout.LocalToCell(transform.localPosition); transform.localPosition = gridLayout.CellToLocal(cellPosition); }}