Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Correct way to block mouse clicks on the UI from being acted upon by the main game?

Discussion in 'UGUI & TextMesh Pro' started by FissicsPeep, Apr 18, 2024.

  1. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    80
    Hi,

    If I have an interactive user interface in-game (think SimCity, the Sims or an in-game level editor...), where the mouse is used to interact with the 2D UI and the 3D game world, what is the correct way to stop the mouse clicks being used by the game world if the player was clicking the UI over the top?

    I see posts about IsPointerOverGameObject(), but this seems to be an API that dates back a long time and is no longer in the documentation. Is it still the way to go, or is there something newer or better?

    Thanks!