My lights don't work with On Click() when I click the button.
I was just testing out the built-in On Click () but when I click the button, the lights do not want to enable. I know this is possible to do with scripting, but I want to know why this does not work. Do I need to add something extra? Here is an image of how I set it up using the built-in event. Note that the third one is different. That was only to test it in another way:
Answer by Jessespike · Sep 13, 2016 at 08:10 PM
Toggling lights with OnClick does work. Not sure why it's not working for you, the image looks fine. Are you sure you dropped in the correct lights and GameObject to OnClick? I'd also double check if the GameObject is inactive when trying to enable lights, and vice versa, is the GameObject active and the lights disabled.
Thank you for your reply @Jessespike.
Here are the lights I dropped onto it from the Hierarchy:
And here are my light settings:
The button is on a canvas and when I am in play mode, I should be able to click it and it must turn the lights on or off. Do I have to do something with the EventSystem that was created when I made the canvas and buttons?
Shouldn't have to do anything with EventSystem. These new images don't reveal anything. Don''t know what to tell you. Clear the OnClick list and try again I guess.
What version of Unity do you use? $$anonymous$$aybe if I update to beta it could fix it?
It looks like the whole button is inactive. Could there be something in front of it?
Your answer
![](https://koobas.hobune.stream/wayback/20220612092731im_/https://answers.unity.com/themes/thub/images/avi.jpg)