x


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.

more ▼

asked Jul 14 '12 at 01:56 AM

decamonos1 gravatar image

decamonos1
1 3 8 9

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 14 '12 at 03:08 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Thanks! And it's for a piano key, which is why I talked about keys.

Jul 14 '12 at 05:39 AM decamonos1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x195
x82
x39
x29

asked: Jul 14 '12 at 01:56 AM

Seen: 362 times

Last Updated: Jul 14 '12 at 05:39 AM