Hi All,
What is the short way of doing this?
Vector3[] positions = new Vector3[3];
void Start() {
positions [0] = new Vector3 (1, 0, 0);
positions [1] = new Vector3 (0, 0, -1);
positions [2] = new Vector3 (0, 0, 1);
}
Any help much appreciated!
Hi All,
What is the short way of doing this?
Vector3[] positions = new Vector3[3];
void Start() {
positions [0] = new Vector3 (1, 0, 0);
positions [1] = new Vector3 (0, 0, -1);
positions [2] = new Vector3 (0, 0, 1);
}
Any help much appreciated!
You could try something like :
Vector3[] positions = new Vector3[3]{new Vector3 (1, 0, 0),new Vector3 (0, 0, -1),new Vector3 (0, 0, 1)};
In a more global way, you can initialize an array with :
Type[] array = new Type[nb elements]{element0, element1,....};
Thanks Darholm.
QualitiesOfDarholm.Add("Awesomeness");
You’re welcome
You don’t to specify the number of elements, or the type. This does the same thing:
Vector3[] positions = {
new Vector3(1, 0, 0),
new Vector3(0, 0, -1),
new Vector3(0, 0, 1)
};
So it does, thanks Baste!