- Home /
The question is answered, right answer was accepted
weird compilation error
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 ...)
Answer by KiraSensei · Oct 02, 2012 at 05:22 PM
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.
Answer by dvidunis · Sep 30, 2012 at 09:34 PM
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.
I'll try your proposals. The posted error is the WHOLE error :)
This is actually a problem because it is clearly not understandable :)
I added a "!=null" in the if statement (it's a gameobject, not a boolean or a string) and it changed nothing. Anyone else has an idea of the problem ?
Follow this Question
Related Questions
How do I use a toolbar? 1 Answer
compiler errors with the fps tutorial 0 Answers
Custom Build step before compilation 1 Answer
Errors are appearing but i don't know how to fix these... 1 Answer