Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Don't raycast if you click over a button

Discussion in 'Scripting' started by hum642tic144, May 19, 2022.

  1. hum642tic144

    hum642tic144

    Joined:
    Feb 4, 2022
    Posts:
    18
    Hello, I have a scene where users can click over a terrain to set a position. This click launchs ray and gets the hit position over the terrain. This scene also have some buttons on which users can interact. My problem is that, if users interact with the buttons , the raycast also launchs and it hit the terrain modifying the position. How can I avoid the raycast to be launched if I interact with a button?

    Thanks!
     
  2. Zalosath

    Zalosath

    Joined:
    Sep 13, 2014
    Posts:
    671
    https://answers.unity.com/questions/1410936/how-to-prevent-a-ui-element-from-clicking-the-game.html
     
    hum642tic144 likes this.
  3. hum642tic144

    hum642tic144

    Joined:
    Feb 4, 2022
    Posts:
    18