How to create and use array in Unity using C#
Features of builtin array in Unity
// define an empty array
float[] values;
// define an array length equal 5
int[] values = new int[5];
// define a 3-demension array
int[,,] values = new int[10,20,30];
// define an array with values
int[] values = new int[] {1, 2, 3, 4}
// get the array length
Debug.Log(values.Length);
If you want an array which has a flexible length, you can use List
and ArrayList
.
Join the newsletter to receive the latest updates in your inbox.