void OnGUI() { if (skin != null) { GUI.skin = skin; } if (Input.GetKeyDown("h")) { ShowHelp(); } JMessageData toRemove = null; if (messages.Count != 0) { GUILayout.BeginArea(new Rect(128 + 32, 16, 420, Screen.height - 32)); float t = Time.time; foreach (JMessageData d in messages) { if (d.startTime <= t) { GUILayout.Label(d.str); } if (d.endTime < t) { toRemove = d; } } if (toRemove != null) { messages.Remove(toRemove); } GUILayout.EndArea(); } }
public void AddMessage(string msg, float delay, float timeout) { float t = Time.time; JMessageData d = new JMessageData(); d.str = msg; d.startTime = t + delay; d.endTime = t + delay + timeout; messages.Insert(0, d); }