I am making a combat log and here is my code:
using UnityEngine;
using System.Collections;
public class Log : MonoBehaviour {
public string[] lines;
int firstEmpty;
void Start () {
}
// Update is called once per frame
void Update () {
firstEmpty = System.Array.IndexOf(lines, null);
}
void OnGUI(){
GUI.Box (new Rect(5, Screen.height- 200 , 300, 200), "Log");
for(int line = 0; line < lines.Length; line++){
GUI.Label(new Rect(7, (Screen.height- 200 + 175) - (20 * line), 200, 20), lines[line]);
}
}
public void newLine(string log){
firstEmpty = System.Array.IndexOf(lines, null);
lines[firstEmpty + 1] = log;
}
}
It only displays one label and i want it to display all 9 lines. Thanks for the help.