Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Vector2.this[int]

public float this[int];

Description

Access the x or y component using [0] or [1] respectively.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Vector2 p; void Example() { p[1] = 5; } }