文档

Unity Engine

Unity Engine

CellToLocalInterpolated(Vector3)

Converts an interpolated cell position in floats to local position space.
阅读时间1 分钟最后更新于 1 个月前

Definition

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

Parameters

cellPosition

Interpolated cell position to convert.

Returns

Type

Description

Vector3Local position of the cell position.

Remarks

Returns the local position in floats.

Examples

// Snap the GameObject to parent GridLayout center of cellusing UnityEngine;public class ExampleClass : MonoBehaviour{ void Start() { GridLayout gridLayout = transform.parent.GetComponent<GridLayout>(); Vector3Int cellPosition = gridLayout.LocalToCell(transform.localPosition); transform.localPosition = gridLayout.CellToLocalInterpolated(cellPosition + new Vector3(.5f, .5f, .5f)); }}