Hello !
I’m working on some UI stuff, and I tried to enable/disable a gameobject but I have a very weird error :
!IsActive () && !m_RunInEditMode
And that’s it …
Here is the code line :
if (text1) text1.gameObject.active = false;
This error is not fatal, I still can play the game.
I saw some questions like that in google, but nothing is helping. If someone has an idea …
EDIT : up ! It happens only in runtime…
EDIT 2 : I just found a topic telling that activating/deactivating gameobjects in OnGui method is not safe. Is there a solution to avoid that error to appear (I really need to activate/deactivate my gameobjects …)
if text1 is a boolean (TRUE/FALSE) change it to:
if (text1 == TRUE)
text1.gameObject.active = false;
else, if it is a string (abc/123), change it to:
if (text1 == “”)
text1.gameObject.active = false;
and if you will post the WHOLE error we can help you more.
Actually I found a simple bypass (specific to my case…).
The problem is apparently that activate/deactivate gameobjects in OnGui() method is not safe at all. I don’t know why but that’s the way it is … Instead of deactivating it, I Get my text mesh component and write “” in the text and disable all other components. This way it works, no more weird error. If someone else has a better solution, please contact me.