I have this simple code to enable/disable an image effect but its returning null, I have the effect added to my camera and it is initially enabled but GetComponent and variants of fail to return a reference to it. It works fine on the SSAOEffect but not on the ColorCorrectionEffect either, any ideas what might be going on
Thanks,
if (funkyOn)
{
cam.GetComponent<GlowEffect>().enabled=true;
}
else
{
cam.GetComponent<GlowEffect>().enabled=false;
}
Are you using Unityscript or c#? For unityscript GetComponent**.**() notice the period between GetComponent and < if you need a generic. See this page for good information on the different ways to get a component.
I’m using c#, the debugger in MonoDevelop just throws a NullReference exception, the Unity console says the same thing, its just odd that its specific effects thats the problem…