ドキュメント

Unity Engine

Unity Engine

CellToWorld(Vector3Int)

Converts a cell position to world position space.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

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

Parameters

cellPosition

Cell position to convert.

Returns

Type

Description

Vector3World position of the cell position.

Examples

// Snap the GameObject to parent GridLayoutusing UnityEngine;public class ExampleClass : MonoBehaviour{ void Start() { GridLayout gridLayout = transform.parent.GetComponentInParent<GridLayout>(); Vector3Int cellPosition = gridLayout.WorldToCell(transform.position); transform.position = gridLayout.CellToWorld(cellPosition); }}