Hello,
I’m working on what will be a universal script for talking to NPCs in my game. The length of the string will be determined in the inspector, as well as any text that will be said will be entered there as well. So what I’m trying to do is make it so that when you press a key (E), it increases the array by 1 (thus changing the text on screen), and when the array reaches its end, I will have it close the text box (that part isn’t in yet). So my question is this: how do I increase the array by one? I’ve looked everywhere for the past hour and have had no luck, even though the answer sounds simple at least. Here’s the (relevant) code I’m using:
void OnGUI () {
if(talking == true){
GUI.Box(new Rect(30,30,650,120), "");
GUI.Box(new Rect(40,40,100,100), "faceplate");
GUI.Label (new Rect (150,40,650,120), mainText[0]);
if(Input.GetKeyDown(KeyCode.E)){
for(int i = 0; i <= mainText.Length-1; i++){
//make mainText[] go to the next element in its index
}
}
}
}
I think the answer is very simple, but I really couldn’t find anything. Any help is appreciated, thanks