Adding an element to an array via script C#
Hey guys, I seem to be having a problem adding an element to an array. I want to increase the size of the array but I can't figure it out. I've tried everything possible.
I am trying to increase the size here: if (waveFake != 0) { waves[].; map.GetComponent<MapGenerator> ().maps [0].seed = Random.Range (2, 10); map.GetComponent<MapGenerator> ().maps [0].obstaclePercent = Random.Range (0.2f, 0.4f); map.GetComponent<MapGenerator> ().maps [0].foregroundColour = new Color (Random.value, Random.value, Random.value); map.GetComponent<MapGenerator> ().maps [0].backgroundColour = new Color (Random.value, Random.value, Random.value); map.GetComponent<MapGenerator> ().GenerateMap (); canvas.SetActive (false); controls.SetActive (true); } } }
http://wiki.unity3d.com/index.php/Choosing_the_right_collection_type
Go with Generic List.
Also, you need to sort out the arrangement of your code, there.