- Home /
Question by
decamonos1 · Jul 14, 2012 at 01:56 AM ·
nullfunctionsif statementoperator
How to check if a function is null?
I tried to use this code to disable a light that appears when an in game key is pressed.
if (OnMouseDown == null) { key.light.enabled = false; }
Instead I received an Operator
==' cannot be applied to operands of type method group' and null'
Is there an easier way to do this, or to fix my code?
Thank you.
Comment
Best Answer
Answer by Eric5h5 · Jul 14, 2012 at 03:08 AM
Functions can't be null. Put the code in OnMouseUp instead. Although talking about pressing keys doesn't make a lot of sense when using OnMouseDown/Up so I don't know if that's what you actually want.
Thanks! And it's for a piano key, which is why I talked about keys.