using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using MuHua; /// /// 输入模块 /// public class ModuleInput : ModuleSingle { /// 当前输入模式 public static EnumInputMode inputMode; /// 鼠标指针位置 public static Vector3 mousePosition; /// 转换模式事件 public static event Action OnInputMode; /// 临时禁用事件 public static event Action OnTemporarilyDisable; private static bool isPointerOverUIObject;// 指针是否在UI上 /// 指针是否在UI上 public static bool IsPointerOverUIObject => isPointerOverUIObject; /// 设置输入模式 public static void Mode(EnumInputMode mode) { inputMode = mode; OnInputMode?.Invoke(mode); } /// 临时禁用输入 public static void TemporarilyDisable(bool value) => OnTemporarilyDisable?.Invoke(value); protected override void Awake() => NoReplace(); private void Update() { #if UNITY_STANDALONE //电脑平台 isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(); #elif UNITY_WEBGL //WebGL平台 isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(); #elif UNITY_ANDROID //安卓平台 isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId); #elif UNITY_IOS //苹果平台 isPointerOverUIObject = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId); #endif } }