clicks pass through UI elements on android
I have 2d objects that respond to mouse clicks. There is a UI panel For the whole screen and when I click on this panel, clicks are triggered on objects under the UI panel. How to fix it? I do it on the phone. Unity Version 2019 This code works on a PC, but not on a phone public void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject() || EventSystem.current.currentSelectedGameObject != null) { } else { WoodFarmPanel.SetActive(true); }
}
Answer by ATate · 6 days ago
@Urtay On the rear panel make sure it is has an Image component and it's "Raycast Target" set to true. This will consume any clicks that would pass below.
That's right, but nothing works... Maybe I said the wrong thing. Clicks on the UI touch objects that are under the UI, 2d sprite, etc., I want to get rid of this
Your answer
Follow this Question
Related Questions
I want to spawn objects probabilistically. 0 Answers
Instantiating A group of platform and moving them down 0 Answers
How to change Sprite Image when it reaches 90 degrees? 0 Answers
Unity Gradle Build Error 2019.3.10f 0 Answers
Can not load the next scene 0 Answers