using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using MuHua; /// /// 输入模块 /// public class ModuleInput : ModuleSingle { /// 当前输入模式 public static InputMode Current; /// 回退输入模式 public static InputMode BackMode; /// 鼠标指针位置 public static Vector2 mousePosition; /// 转换模式事件 public static event Action OnInputMode; /// 指针是否在UI上 private static bool isPointerOverUIObject; /// 指针是否在UI上 public static bool IsPointerOverUIObject => isPointerOverUIObject; /// 设置输入模式 public static void Settings(InputMode mode) { BackMode = Current; Current = mode; OnInputMode?.Invoke(Current); } /// 设置输入模式 public static void Back() { Current = BackMode; OnInputMode?.Invoke(Current); } 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 } } /// /// 输入模式 /// public enum InputMode { None,// 无 FashionDesign,// 服装设计 OrnamentDesign,// 配饰设计 FashionDisplay,// 服装展示 }