GetComponent<CanvasRenderer>().enabled = !GetComponent<CanvasRenderer>().enabled;
//Why I can't do this?
//Sorry for the title
I dunno. Why can’t you do it? Does it throw an error? Not work? Make unity blow up? Set fire to your hard drive? Hack into the US government computers and launch nukes at Saturn?
according to the scripting reference… there isn’t an “enabled” attribute
(could just be “docs ” though)
You’re not wrong - it’s on Behaviour: http://docs.unity3d.com/ScriptReference/Behaviour-enabled.html
What the OP probably wants to do is call SetActive in the GameObject. This will do essentially the same thing.
Not necessarily. If you want to turn off a single component, you don’t want to turn off the whole object. That said, in this context, you are most likely right, especially since you can’t disable a canves renderer component, but it is important to note the difference between the two.
Well i can SetAlpha wich fit what i was looking for, thanks