Hover and click color did not change

I added Start button on the screen but the hover and click color wont effect after I changed the settings in button script. what am I doing wrong?

Hello Muhammad,

Does this occur when you run the game within Unity, or as a separate build?

Within unity!

1 Like

Hi,

If you select your button in the Hierarchy, then, in the Inspector, scroll down to the OnClick() event handlers section, what do you have there? Could you provide a screenshot.

Also, perhaps copy/paste your Button script in your reply also.


See also;

Ok, so nothing wired up at the moment for the actual click, it’s just the colour changes you are concerned about not happening?

Which version of Unity are you running?

yes.4.x

Ok, give me a sec, I have a 4.7.2 here, let me test something…


Updated Wed Dec 20 2017 00:19

Hi,

Ok, I just wanted to check something with regards to the order of the Text fields and the Button under the canvas.

I have recreated what you have, from what I can tell, and in 4.7.2 it works fine. Where I could replicate your issue was when I had the Text fields actually over the button in the scene, with the button at the top of the Hierarchy under the canvas and the two Text GameObjects beneath it.

If you would like to zip up your project files and upload them to your next reply I will happily take a look for you to see if I can spot anything else.

2ndProject.zip (140.5 KB)

Hi,

Thanks for this.

Ironically I should have spotted this from the screenshot!

You don’t have the Event System GameObject in the Hierarchy. Typically when you create a new Canvas GameObject an Event System GameObject is created also, it is this which handles events such as mouse over / hover from input devices.

To resolve, right-click in the Hierarchy (not on an existing GameObject), select UI -> Event System.

Run the game :slight_smile:


See also;

Privacy & Terms