1
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 基础输入
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public class InputBasic : MonoBehaviour {
|
||||
public Vector3 mousePosition;
|
||||
|
||||
#region 输入系统
|
||||
/// <summary> 鼠标位置 </summary>
|
||||
public void OnMousePosition(InputValue inputValue) {
|
||||
mousePosition = inputValue.Get<Vector2>();
|
||||
ModuleInput.mousePosition = mousePosition;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dee866dfe25bee147af6c082a02e6088
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 输入 - 控制
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public abstract class InputControl : MonoBehaviour {
|
||||
|
||||
protected virtual void Awake() {
|
||||
ModuleInput.OnInputMode += ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy() {
|
||||
ModuleInput.OnInputMode -= ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
/// <summary> 输入模式 </summary>
|
||||
protected abstract void ModuleInput_OnInputMode(InputMode mode);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fccf5d06f2bfe274ca0c36cb9f830a89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea1d3ff12fa75374db81a3fa96568dbf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单 - 输入
|
||||
/// </summary>
|
||||
public class InputMenu : InputControl {
|
||||
|
||||
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
||||
// throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
#region 输入系统
|
||||
/// <summary> 鼠标右键 </summary>
|
||||
public void OnMouseRight(InputValue inputValue) {
|
||||
UIMenuManager.I.Open();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c410af27a0301a42af9f1934da770a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 输入模块
|
||||
/// </summary>
|
||||
public class ModuleInput : ModuleSingle<ModuleInput> {
|
||||
|
||||
/// <summary> 当前输入模式 </summary>
|
||||
public static InputMode Current;
|
||||
/// <summary> 回退输入模式 </summary>
|
||||
public static InputMode BackMode;
|
||||
/// <summary> 鼠标指针位置 </summary>
|
||||
public static Vector2 mousePosition;
|
||||
/// <summary> 转换模式事件 </summary>
|
||||
public static event Action<InputMode> OnInputMode;
|
||||
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
private static bool isPointerOverUIObject;
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
public static bool IsPointerOverUIObject => isPointerOverUIObject;
|
||||
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Settings(InputMode mode) {
|
||||
BackMode = Current;
|
||||
Current = mode;
|
||||
OnInputMode?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 输入模式
|
||||
/// </summary>
|
||||
public enum InputMode {
|
||||
None,// 无
|
||||
|
||||
FashionDesign,// 服装设计
|
||||
|
||||
OrnamentDesign,// 配饰设计
|
||||
|
||||
FashionDisplay,// 服装展示
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 660f596e493d2b547b176b764baa4a7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user