Vector3Int Constructor
Declaration
public Vector3Int(int x, int y, int z);Параметры
| Параметр | Описание |
|---|---|
| x | X-компонент Vector3Int. |
| y | Компонент Y Vector3Int. |
| z | Z-компонент Vector3Int. |
Описание
Инициализирует и возвращает экземпляр нового Vector3Int с компонентами x, y, z.
// Attach this script to a GameObject. // Attach a Tilemap component to the GameObject (Click Add Component button in the Inspector window and go to 2D<Tilemap) // This script sets a Tile at a Vector3Int position using UnityEngine; using UnityEngine.Tilemaps;
public class Vector3IntCtorExample : MonoBehaviour { Vector3Int m_Position; Tilemap m_Tilemap; Tile m_Tile;
void Start() { // Position to set the Tile at m_Position = new Vector3Int(1, 5, -2); // Fetch the Tilemap you attach to the GameObject m_Tilemap = GetComponent<Tilemap>(); // Create a Tile m_Tile = ScriptableObject.CreateInstance<Tile>(); }
void Update() { // Sets a Tile at the position if a Tile does not exist at the position on the Tilemap if (!m_Tilemap.HasTile(m_Position)) m_Tilemap.SetTile(m_Position, m_Tile); } }
Declaration
public Vector3Int(int x, int y);Параметры
| Параметр | Описание |
|---|---|
| x | X-компонент Vector3Int. |
| y | Компонент Y Vector3Int. |
Описание
Инициализирует и возвращает экземпляр нового Vector3Int с компонентами x и y и устанавливает z на нуль.