- Home /
Question by
iksanmohamad39 · Sep 13, 2021 at 12:27 AM ·
unity 2dmobile devices
Prevent mouse input trough GUI button on mobile game Unity 2019.4
Hello Community, so i am working on mobile game i use mouse input to control the player, in mobile device its working as touch,so when i press pause button its input trough GUI button in mobile device, but not at editor, Thanks
Comment
Answer by UncleanWizard · Sep 13, 2021 at 05:21 AM
You can check if the mouse/touch is over a ui object using the event system.
Code
using UnityEngine.EventSystems; // needed
if(!EventSystem.current.IsPointerOverGameObject()) { // Do your thing. }