fix new input mouse system

This commit is contained in:
2023-12-10 19:56:46 +02:00
parent 72a210f142
commit c24abb2964
5 changed files with 30 additions and 35 deletions
+3 -3
View File
@@ -1383,9 +1383,9 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 349281313} m_Father: {fileID: 349281313}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 250, y: -90}
m_SizeDelta: {x: 480, y: 0} m_SizeDelta: {x: 480, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &249161732 --- !u!114 &249161732
+14 -20
View File
@@ -57,17 +57,6 @@ public class CameraSystem : MonoBehaviour
transform.position = Player.Instance.transform.position; transform.position = Player.Instance.transform.position;
} }
private void OnEnable()
{
InputManager.Instance.CameraAction.Rotate.performed += OnCameraRotate;
InputManager.Instance.CameraAction.Zoom.performed += OnCameraZoom;
}
private void OnDisable()
{
InputManager.Instance.CameraAction.Rotate.performed -= OnCameraRotate;
InputManager.Instance.CameraAction.Zoom.performed -= OnCameraZoom;
}
private void Update() private void Update()
@@ -79,14 +68,21 @@ public class CameraSystem : MonoBehaviour
HandleCameraMovement(cameraMove); HandleCameraMovement(cameraMove);
} }
//float rotate = InputManager.Instance.CameraAction.Rotate.ReadValue<float>(); float rotateDir = InputManager.Instance.CameraAction.Rotate.ReadValue<Vector2>().x;
//if (rotate != 0) if (rotateDir != 0)
//{ {
//HandleCameraRotation(rotate, _rotateSpeed); HandleCameraRotation(rotateDir, _rotateSpeed);
//} }
float zoomAmount = InputManager.Instance.CameraAction.Zoom.ReadValue<Vector2>().y;
if (zoomAmount != 0)
{
HandleCameraZoom_MoveY(zoomAmount);
}
//HandleCameraZoom_MoveY();
//HandleCameraZoom_FOV(); //HandleCameraZoom_FOV();
//HandleCameraZoom_MoveForward(); //HandleCameraZoom_MoveForward();
//HandleCameraZoom_MoveY();
} }
private void HandleCameraZoom_MoveForward() private void HandleCameraZoom_MoveForward()
@@ -108,10 +104,8 @@ public class CameraSystem : MonoBehaviour
_cinemachineTransposer.m_FollowOffset = _followOffset; _cinemachineTransposer.m_FollowOffset = _followOffset;
} }
private void OnCameraZoom(InputAction.CallbackContext context) private void HandleCameraZoom_MoveY(float _zoomAmount)
{ {
float _zoomAmount = InputManager.Instance.CameraAction.Rotate.ReadValue<Vector2>().y;
_followOffset.y += _zoomAmount; _followOffset.y += _zoomAmount;
_followOffset.y = Mathf.Clamp(_followOffset.y, _followOffsetMinY, _followOffsetMaxY); _followOffset.y = Mathf.Clamp(_followOffset.y, _followOffsetMinY, _followOffsetMaxY);
@@ -1,6 +1,7 @@
using System; using System;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class InGameMouseHandler : MonoBehaviour public class InGameMouseHandler : MonoBehaviour
{ {
@@ -49,7 +50,7 @@ public class InGameMouseHandler : MonoBehaviour
void Update() void Update()
{ {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
if(EventSystem.current.IsPointerOverGameObject()) if(EventSystem.current.IsPointerOverGameObject())
{ {
return; return;
@@ -70,7 +70,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
""id"": ""d269ae49-9dbe-4e7c-9a80-1276e29898d8"", ""id"": ""d269ae49-9dbe-4e7c-9a80-1276e29898d8"",
""expectedControlType"": ""Vector2"", ""expectedControlType"": ""Vector2"",
""processors"": """", ""processors"": """",
""interactions"": """", ""interactions"": ""Hold"",
""initialStateCheck"": true ""initialStateCheck"": true
}, },
{ {
@@ -166,7 +166,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
""id"": ""23cd5caa-3052-46e5-b888-9b7097cffc1b"", ""id"": ""23cd5caa-3052-46e5-b888-9b7097cffc1b"",
""path"": ""<Mouse>/delta"", ""path"": ""<Mouse>/delta"",
""interactions"": """", ""interactions"": """",
""processors"": """", ""processors"": ""NormalizeVector2"",
""groups"": """", ""groups"": """",
""action"": ""Rotate"", ""action"": ""Rotate"",
""isComposite"": false, ""isComposite"": false,
@@ -186,7 +186,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
{ {
""name"": ""left"", ""name"": ""left"",
""id"": ""70123c0f-2726-4ff5-9a04-83d845177032"", ""id"": ""70123c0f-2726-4ff5-9a04-83d845177032"",
""path"": ""<Keyboard>/q"", ""path"": ""<Keyboard>/e"",
""interactions"": """", ""interactions"": """",
""processors"": """", ""processors"": """",
""groups"": """", ""groups"": """",
@@ -197,7 +197,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
{ {
""name"": ""right"", ""name"": ""right"",
""id"": ""81380d14-07da-4e3e-b74d-13a4bc2edc1d"", ""id"": ""81380d14-07da-4e3e-b74d-13a4bc2edc1d"",
""path"": ""<Keyboard>/e"", ""path"": ""<Keyboard>/q"",
""interactions"": """", ""interactions"": """",
""processors"": """", ""processors"": """",
""groups"": """", ""groups"": """",
@@ -210,7 +210,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
""id"": ""8e2aefc6-bf10-4653-8782-6b92d5efc35a"", ""id"": ""8e2aefc6-bf10-4653-8782-6b92d5efc35a"",
""path"": ""<Mouse>/scroll"", ""path"": ""<Mouse>/scroll"",
""interactions"": """", ""interactions"": """",
""processors"": ""NormalizeVector2"", ""processors"": ""NormalizeVector2,InvertVector2(invertX=false)"",
""groups"": """", ""groups"": """",
""action"": ""Zoom"", ""action"": ""Zoom"",
""isComposite"": false, ""isComposite"": false,
@@ -48,7 +48,7 @@
"id": "d269ae49-9dbe-4e7c-9a80-1276e29898d8", "id": "d269ae49-9dbe-4e7c-9a80-1276e29898d8",
"expectedControlType": "Vector2", "expectedControlType": "Vector2",
"processors": "", "processors": "",
"interactions": "", "interactions": "Hold",
"initialStateCheck": true "initialStateCheck": true
}, },
{ {
@@ -144,7 +144,7 @@
"id": "23cd5caa-3052-46e5-b888-9b7097cffc1b", "id": "23cd5caa-3052-46e5-b888-9b7097cffc1b",
"path": "<Mouse>/delta", "path": "<Mouse>/delta",
"interactions": "", "interactions": "",
"processors": "", "processors": "NormalizeVector2",
"groups": "", "groups": "",
"action": "Rotate", "action": "Rotate",
"isComposite": false, "isComposite": false,
@@ -164,7 +164,7 @@
{ {
"name": "left", "name": "left",
"id": "70123c0f-2726-4ff5-9a04-83d845177032", "id": "70123c0f-2726-4ff5-9a04-83d845177032",
"path": "<Keyboard>/q", "path": "<Keyboard>/e",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "",
@@ -175,7 +175,7 @@
{ {
"name": "right", "name": "right",
"id": "81380d14-07da-4e3e-b74d-13a4bc2edc1d", "id": "81380d14-07da-4e3e-b74d-13a4bc2edc1d",
"path": "<Keyboard>/e", "path": "<Keyboard>/q",
"interactions": "", "interactions": "",
"processors": "", "processors": "",
"groups": "", "groups": "",
@@ -188,7 +188,7 @@
"id": "8e2aefc6-bf10-4653-8782-6b92d5efc35a", "id": "8e2aefc6-bf10-4653-8782-6b92d5efc35a",
"path": "<Mouse>/scroll", "path": "<Mouse>/scroll",
"interactions": "", "interactions": "",
"processors": "NormalizeVector2", "processors": "NormalizeVector2,InvertVector2(invertX=false)",
"groups": "", "groups": "",
"action": "Zoom", "action": "Zoom",
"isComposite": false, "isComposite": false,