Vector3.this [int index] 操作索引


var this[index : int] : float

Description描述

Access the x, y, z components using [0], [1], [2] respectively.

使用[0], [1], [2]分别访问组件x, y, z组件。简单来说就是用索引号代替x, y, z组件。

  • C#

  • JavaScript

using UnityEngine;using System.Collections;public class example : MonoBehaviour {public Vector3 p;public void Awake() {p[1] = 5;}}
var p : Vector3;//等同于p.y = 5p[1] = 5; 


,