array syntax in unity code example
Example 1: unity define array
int[] arr1 = new int[3];
// Create an integer array with 3 elements
var arr2 = new int[3];
// Same thing, just with implicit declaration
var arr3 = new int[] { 1, 2, 3 };
// Creates an array with 3 elements and sets values.
Example 2: array in c# unity
using UnityEngine;
using System.Collections;
public class Arrays : MonoBehaviour
{
public GameObject[] players;
void Start ()
{
players = GameObject.FindGameObjectsWithTag("Player");
for(int i = 0; i < players.Length; i++)
{
Debug.Log("Player Number "+i+" is named "+players[i].name);
}
}
}