I have a script that I swore worked fine in 4.3 but performs strangely in 4.5:
The debug output from using this script in my project is “enabled”, True, “disabled”, “enabled”, True, “showing”, “showing”, “showing”… etc…
In other words, the first time it triggers, it refuses to show the GUI text. Only the second time it gets triggered does the text show up:
using UnityEngine;
using System.Collections;
public class TileEventMessage : TileEvent {
public Font font;
public string message;
private bool permanent;
private bool messageShown;
public override void Start () {
// Temp stuff that should be overwritten
//permanent = false;
//message = "DEFAULT MESSAGE";
messageShown = false;
enabled = false;
}
public override void OnTriggerEnter (Collider other) {
if (!permanent && messageShown) {
return;
}
Debug.Log ("enabling");
enabled = true;
Debug.Log (enabled);
}
public override void OnTriggerExit (Collider other) {
if (!permanent) {
messageShown = true;
}
Debug.Log ("disabling");
enabled = false;
}
void OnGUI () {
Debug.Log ("showing");
GUI.skin.font = font;
GUILayout.Label(message);
}
void SetMessage (string m) {
message = m;
}
void SetPermanence (bool p) {
permanent = p;
}
}