Quantcast
Channel: Latest Questions by Pinsukka
Viewing all articles
Browse latest Browse all 13

How to prevent touch going through UI?

$
0
0
I have been reading about this problem a lot but it seems I just can't figure this out. The problem is that touch goes through my UI elements and activates buttons behind UI. I have tried using the event system to prevent this and it works fine with mouse on PC, but when I build the game touches still go through on Android devices. This is what I've tried: if(!EventSystem.current.IsPointerOverGameObject ()) { //Button script here } I also tried this without any success: if(!EventSystem.current.IsPointerOverGameObject (Input.GetTouch (0).fingerId)) { //Button script here } I suspect I need to add something else to the code above to make it work, but what might that be? I have also tried setting the button gameobjects inactive when the UI layout is activated, but for some weird reason the UI acts like the gameobjects still exist even when they have been set completely inactive. I have no idea how this is even possible... If someone could explain to me how to fix this it would be really nice.

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>