diff --git a/Assets/PlayerInputControl.inputactions b/Assets/PlayerInputControl.inputactions
index 6db89102e..51f720468 100644
--- a/Assets/PlayerInputControl.inputactions
+++ b/Assets/PlayerInputControl.inputactions
@@ -1,4 +1,5 @@
{
+ "version": 1,
"name": "PlayerInputControl",
"maps": [
{
diff --git a/Assets/Scripts/Fishing2/Camera/InputComponent.cs b/Assets/Scripts/Fishing2/Camera/InputComponent.cs
index 0dc4e48d8..a6cebb9d3 100644
--- a/Assets/Scripts/Fishing2/Camera/InputComponent.cs
+++ b/Assets/Scripts/Fishing2/Camera/InputComponent.cs
@@ -1,9 +1,156 @@
-using NBC.Entitas;
+using System;
+using NBC.Entitas;
+using NBC.Entitas.Interface;
+using UnityEngine.InputSystem;
namespace NBF.Fishing2
{
public class InputComponent : Entity
{
-
+ public PlayerInputControl PlayerInputControl { get; set; }
+
+ ///
+ /// 执行输入事件
+ ///
+ public event Action OnUIPerformed;
+
+ ///
+ /// 执行输入事件完毕
+ ///
+ public event Action OnUICanceled;
+
+ ///
+ /// 执行输入事件
+ ///
+ public event Action OnPlayerPerformed;
+
+ ///
+ /// 执行输入事件完毕
+ ///
+ public event Action OnPlayerCanceled;
+
+ ///
+ /// 手柄输入
+ ///
+ public static bool IsControllerInput;
+
+ ///
+ /// ui阻止游戏输入
+ ///
+ public static bool IsUIStopInput;
+
+ public void OnUIButtonPerformed(InputAction.CallbackContext context)
+ {
+ OnUIPerformed?.Invoke(context.action.name);
+ }
+
+ public void OnUIButtonCanceled(InputAction.CallbackContext context)
+ {
+ OnUICanceled?.Invoke(context.action.name);
+ }
+
+ public void OnPlayerButtonPerformed(InputAction.CallbackContext context)
+ {
+ if (IsUIStopInput) return;
+ var actionName = context.action.name;
+ // if (actionName == "Op1")
+ // {
+ // OnOp1Action?.Invoke(true);
+ // }
+ // else if (actionName == "Op2")
+ // {
+ // OnOp2Action?.Invoke(true);
+ // }
+
+ OnPlayerPerformed?.Invoke(actionName);
+ }
+
+ public void OnPlayerButtonCanceled(InputAction.CallbackContext context)
+ {
+ if (IsUIStopInput) return;
+ var actionName = context.action.name;
+ // if (actionName == "Op1")
+ // {
+ // OnOp1Action?.Invoke(false);
+ // }
+ // else if (actionName == "Op2")
+ // {
+ // OnOp2Action?.Invoke(false);
+ // }
+ //
+ OnPlayerCanceled?.Invoke(actionName);
+ }
+ }
+
+ public static class InputComponentSystem
+ {
+ public class InputComponentAwakeSystem : AwakeSystem
+ {
+ protected override void Awake(InputComponent self)
+ {
+ self.PlayerInputControl = new PlayerInputControl();
+ self.PlayerInputControl.Enable();
+
+ foreach (var actionMap in self.PlayerInputControl.asset.actionMaps)
+ {
+ actionMap.Enable();
+ if (actionMap.name == "UI")
+ {
+ foreach (var action in actionMap.actions)
+ {
+ if (action.type == InputActionType.Button)
+ {
+ action.performed += self.OnUIButtonPerformed;
+ action.canceled += self.OnUIButtonCanceled;
+ }
+ }
+ }
+ else if (actionMap.name == "Player")
+ {
+ foreach (var action in actionMap.actions)
+ {
+ if (action.type == InputActionType.Button)
+ {
+ action.performed += self.OnPlayerButtonPerformed;
+ action.canceled += self.OnPlayerButtonCanceled;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public class InputComponentDestroySystem : DestroySystem
+ {
+ protected override void Destroy(InputComponent self)
+ {
+ foreach (var actionMap in self.PlayerInputControl.asset.actionMaps)
+ {
+ actionMap.Enable();
+ if (actionMap.name == "UI")
+ {
+ foreach (var action in actionMap.actions)
+ {
+ if (action.type == InputActionType.Button)
+ {
+ action.performed -= self.OnUIButtonPerformed;
+ action.canceled -= self.OnUIButtonCanceled;
+ }
+ }
+ }
+ else if (actionMap.name == "Player")
+ {
+ foreach (var action in actionMap.actions)
+ {
+ if (action.type == InputActionType.Button)
+ {
+ action.performed -= self.OnPlayerButtonPerformed;
+ action.canceled -= self.OnPlayerButtonCanceled;
+ }
+ }
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Global.cs b/Assets/Scripts/Global.cs
index f4080da32..4f512184d 100644
--- a/Assets/Scripts/Global.cs
+++ b/Assets/Scripts/Global.cs
@@ -1,4 +1,5 @@
using System;
+using NBF.Fishing2;
using UnityEngine;
namespace NBF
@@ -7,15 +8,18 @@ namespace NBF
{
public static Global Instance { get; private set; }
+
+ public static InputComponent Input;
+
///
/// 主摄像机
///
- public Camera MainCamera { get; private set; }
+ public static Camera MainCamera { get; private set; }
///
/// 摄像机配置
///
- public CameraScriptObject CameraConfig { get; private set; }
+ public static CameraScriptObject CameraConfig { get; private set; }
private void Awake()
{
diff --git a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs b/Assets/Scripts/Model/Common/Services/Input/InputManager.cs
index c9d867ac0..5594df494 100644
--- a/Assets/Scripts/Model/Common/Services/Input/InputManager.cs
+++ b/Assets/Scripts/Model/Common/Services/Input/InputManager.cs
@@ -70,7 +70,6 @@ namespace NBF
private void Start()
{
-
AddEvent();
}
diff --git a/Assets/Scripts/OnSceneCreate_Init.cs b/Assets/Scripts/OnSceneCreate_Init.cs
index f156b9b52..e2561bc54 100644
--- a/Assets/Scripts/OnSceneCreate_Init.cs
+++ b/Assets/Scripts/OnSceneCreate_Init.cs
@@ -14,8 +14,10 @@ namespace NBF.Fishing2
scene.AddComponent();
scene.AddComponent();
scene.AddComponent();
- scene.AddComponent();
+ var input = scene.AddComponent();
scene.AddComponent();
+
+ Global.Input = input;
}
await FTask.CompletedTask;
diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset
index d1992fefa..d62b2c177 100644
--- a/ProjectSettings/EditorBuildSettings.asset
+++ b/ProjectSettings/EditorBuildSettings.asset
@@ -24,5 +24,5 @@ EditorBuildSettings:
path: Assets/ResRaw/Maps/Map99/Map99.unity
guid: 956b354d2875715418f574fcf501363e
m_configObjects:
- com.unity.input.settings.actions: {fileID: -944628639613478452, guid: d0e3cb5a99f3d324ea14bfe64485b2e4, type: 3}
+ com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 8a314d59348c97b4e96e6eb9b09285a6, type: 3}
m_UseUCBPForAssetBundles: 0