UI Button DOESN'T override scene objects

Funny problem. I have a UI button and objects in the scene. Both are clickable. Problem is, that whenever a player clicks on a UI button, it may also click on an object in the scene, which leads to undesired results. I tried adding a box collider to the UI button but it didn’t help.

How do I solve this?

This example should solve the problem for you

http://docs.unity3d.com/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
You can check if the cursor is over a ui element and if yes , just do not count the click for your scene objects.

1 Like

Many many thanks :slight_smile: