I have a combat log that displays who killed whom but it only works in the first level of a tournament. On second level load and onwards the log is not displayed. Here’s the code:
This function is called OnGUI with *
void CombatWindowFunction(int windowID )
{
GUILayout.Label(combatLog, myStyle);
Debug.Log("We should see the combat log");
}
this line (inside OnGUI) :
windowRect = GUI.Window(4, windowRect, CombatWindowFunction, “Death Log”);
But I know the issues stems from the “int windowID” because my Debug.Log isn’t called on second level load whilst another debug inside OnGUI is.
So since “int windowID” should be unique according to the API, should I reset it on level load or how do I do this?
How can windowID be the problem when you never use windowID? Legacy GUI stuff isn’t really recommended for in game use anymore outside of hidden dev debug displays. Though I thought they finally ripped all this stuff out, but I’m probably wrong.
This Legacy GUI API stopped being used in 2014 or so for games, except for Editor scripts, as Uncle Joe pointed out.
You can persist and perhaps get it working (if it still is functional; I don’t know!), but know that as Joe points out, it will someday stop working in Unity.
Instead, look into the new UI system (now eight years old so not so new anymore!), which lets you visually build your interface and script against it. There’s a LOT of tutorials out there about it and it has become a very well-understood way to make modern user interfaces.
I’m forced to used unity 2017 because of assets depending on that version that would mess up my project if I update, so while I appreciate the age of the this Legacy GUI API, its working in the first level, I’m guessing there’s a reasonable explanation as to why it doesn’t in the subsequent ones, maybe not. Its sole purpose is to display one line of text showing who killed who. But I guess if you or anybody else also have no idea why it only works in the first level load I’ll have to start over…