How to find which script disables my gameobject

Hi guys, im stuck for 2 days now. how do you find which script/gameobject that keeps disabling my gameobject? i have this gameobject that keeps disabled when i run and i couldnt figure which script is causing it. i tried debug.log potential scripts but im lost. is there a way to find which script disables a gameobject?

Hi, it should be possible by implementing a OnDisable() method in one of the scripts that are on this gameobject that gets disabled. This will be called by Unity when another script disables the gameobject. Then, you can use the debugger (visual studio) to set a breakpoint on some line of code inside OnDisable() (just write any dummy code so you can set a breakpoint), attach the debugger to the Editor and press play in the Editor. When the breakpoint is reached, check the callstack window: it will show you all methods that were called until the code that has the breakpoint. Other option is to add a Debug.LogError(“”) in OnDisable: selecting the message in the console when it pops will show the callstack in the detail/lower part of the console. Using the debugger is better as you can inspect variables content and is a tool .