Hello Answers - and thank you very much for your time!
I have a GameObject “LevelManager” with only one object attached: a C# script named “LevelManager”. At some point in development the script began to disable at game start.
I have read through all scripts in the project to find anything that could be the cause. Nothing. I do disable through code, but most of the time I disable/enable Canvases. I have many references to the script, but none of them use “enable = false;”. The references to the script are used to get and set data in public variables.
I use Animations, and perhaps one of those could have been “recording” a click on the disable-box in the Inspector for that object. I have looked through most of my Animations, but I have found nothing. It seems somewhat unlikely too, as I never lock my Inspector and the Animation windows flip to selected object when clicking on another object in the Hierarchy. So it’s pretty hard to accidentally flip check that box while recording animations.
At this point I have an extra script attached with the sole purpose of re-enabling LevelManager.cs. But even when enabling the script at both Awake and at Start and at Update, it is still disabled at that point of starting up, where all the other scripts are trying to get and set data to it.
LevelManager is enabled as default (before starting the debug / running the game).
My question:
- Is there some way of backtracking what disables that particular script. Can I attach a script to the LevelManager object, or maybe add a public void that I call from another scripts Update, that “discovers the cause” and gives me a clue of what is disabling it?
- Can OnDisable() tell me what other object caused the disabling?
(This is the first time I pose a question, and if I have made some mistakes in doing so, I apologize).