“Component” class has no “enabled” variable, but somehow, in JavaScript this works:
gameObject.GetComponent("Halo").enabled = true;
How to enable/disable Halo component in C# ?
Yes, I’m not the first one asking this, but nobody has answered to this question yet…
I really would like to start using C#, not just stick with Unity’s JavaScript.
The Answer:
As Rod Green explained the structure of class inheritance, for “Halo” component, to enable/disable the “Halo” component, you need to access “Behaviour” class.
(gameObject.GetComponent("Halo") as Behaviour).enabled = true;
I’m not really sure what you are asking. However if you have a component (MonoBehaviour) of type “Halo” and wish to enable/disable it then all you need to do is.