null array?
I have been working all day and normally i figure out how to do something after being stuck on it for a while, its amazing ive gotten this far to me but now im stuck, ive been searching up to why this happens, cant find anything, the A appears to be null, i tried removing 0 and making 27 that still made the A or something null, i also wrote a print thing before and that printed out everything but A which would have been null. any help? using UnityEngine; using System.Collections; using System.Collections.Generic;
public class arrayRandom : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
private void Update () {
if (Input.GetKeyDown (KeyCode.G)) {
string[] letters = new string[27];
letters [0] = "A";
letters [1] = "B";
letters [3] = "C";
letters [4] = "D";
letters [5] = "E";
letters [6] = "F";
letters [7] = "G";
letters [8] = "H";
letters [9] = "I";
letters [10] = "J";
letters [11] = "K";
letters [12] = "L";
letters [13] = "M";
letters [14] = "N";
letters [15] = "O";
letters [16] = "P";
letters [17] = "Q";
letters [18] = "R";
letters [19] = "S";
letters [20] = "T";
letters [21] = "U";
letters [22] = "V";
letters [23] = "W";
letters [24] = "X";
letters [25] = "Y";
letters [26] = "Z";
System.Random rnd = new System.Random ();
//print (letters [rnd.Next (0, 26)]);
GetComponent<GUIText> ().text = letters [rnd.Next (0, 26)];
}
}
}
Your answer
Follow this Question
Related Questions
how to not repeat random array 1 Answer
How to pick two random gameobjects in an array at the same time? 1 Answer
Instantiate players in Photon. Error: Index was outside the bounds of the array. 1 Answer
After picking a random object from an array, how to run the functions only for the chosen object? 0 Answers