// Use this for initialization void Start() { ls = GameObject.Find("MasterLevelController").GetComponent <LobbySystem>(); bool[] Array = ls.GetArrayOfPlayerActive(); for (int i = 0; i < Array.Length; i++) { if (Array[i]) { string CameraName = "Camera_" + (i + 1); GameObject.Find(CameraName).SetActive(false); } } }
public void SortPlayersInArray() { bool[] temparray = ls.GetArrayOfPlayerActive(); GameObject tempo = GameObject.Find("Player_1"); playerList = new GameObject[4]; GameObject[] tempGOarray = GameObject.FindGameObjectsWithTag("Player"); playerList = tempGOarray; // Has to do this or the playerlist array might change in size for (int i = 0; i < tempGOarray.Length; i++) { playerList[i] = tempGOarray[i]; } // if both same length if (playerList.Length == tempGOarray.Length) { return; } // Sorting for (int i = 0; i < temparray.Length; i++) { if (temparray[i]) { // Finding thru name string playernametofind = "Player_" + (i + 1); for (int j = 0; j < playerList.Length; j++) { if (playerList[j].name == playernametofind) { GameObject temp = playerList[j]; playerList[j] = playerList[i]; playerList[i] = temp; break; } } } } }