As far as I can tell it's only possible to enable/disable (activate/deactivate) gamneObjects through script but NOT components. Is this correct? If so , it seems odd that I can enable/disable components through the inspector at runtime. Anyone know? I should mention what I'm trying to do is toggle a full screen effect component on/off but instead the script just deactivate the gameobject which hold the effect (ie the camera)
GameObject has .active, and many (though not all) components have .enabled which is equivalent. (The components which don't have that are, in theory, the ones which wouldn't make much sense to deactivate.)
Yeah I tried that but I get ... VideoSettingsControllerScript.js(56,40): BCE0019: 'enabled' is not a member of 'UnityEngine.Component'.
No you were right! Instead of Code (csharp): var myCameraEffect:SSAOEffect; Iwas declaring my component as.. Code (csharp): var myCameraEffect:Component; Now I can use enabled=true; freely. Many thanks!
I have var color_script : SSAOEffect; color_script = GetComponent(ColorCorrectionEffect); color_script.enabled=false; I get error BCE0022: Cannot convert 'System.Type' to 'SSAOEffect'. if I try var color_script : SSAOEffect; function Update () { color_script = GetComponent(ColorCorrectionEffect); color_script.enabled=false; I get errorInvalidCastException: Cannot cast from source type to destination type. Any ideas ?