add new input mouse system
This commit is contained in:
@@ -10,13 +10,13 @@ public class SelectedVisual : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
MouseInputManager.OnSelectedObjectChanged += Mouse_OnSelectedObjectChanged;
|
||||
InGameMouseHandler.OnSelectedObjectChanged += Mouse_OnSelectedObjectChanged;
|
||||
print($"{_selectedObject.name} is subscribed to OnSelectedObjectChanged");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
MouseInputManager.OnSelectedObjectChanged -= Mouse_OnSelectedObjectChanged;
|
||||
InGameMouseHandler.OnSelectedObjectChanged -= Mouse_OnSelectedObjectChanged;
|
||||
print($"{_selectedObject.name} is Unsubscribed to OnSelectedObjectChanged");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ LightingSettings:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: New Lighting Settings
|
||||
m_Name: Lighting Settings
|
||||
serializedVersion: 4
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
@@ -1,5 +1,7 @@
|
||||
using Cinemachine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class CameraSystem : MonoBehaviour
|
||||
{
|
||||
@@ -41,7 +43,6 @@ public class CameraSystem : MonoBehaviour
|
||||
private float _zoomSpeed = 2f;
|
||||
[SerializeField]
|
||||
private float _zoomAmount = 3f;
|
||||
private Vector2 _lastMousePosition;
|
||||
private float _targetFieldOfView = 60f;
|
||||
private CinemachineTransposer _cinemachineTransposer;
|
||||
|
||||
@@ -56,14 +57,36 @@ public class CameraSystem : MonoBehaviour
|
||||
transform.position = Player.Instance.transform.position;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
InputManager.Instance.CameraAction.MouseRotate.performed += OnCameraRotate;
|
||||
InputManager.Instance.CameraAction.Zoom.performed += OnCameraZoom;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
InputManager.Instance.CameraAction.MouseRotate.performed -= OnCameraRotate;
|
||||
InputManager.Instance.CameraAction.Zoom.performed -= OnCameraZoom;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
HandleCameraMovement();
|
||||
HandleCameraRotation();
|
||||
var cameraMove = InputManager.Instance.CameraAction.Move.ReadValue<Vector2>();
|
||||
|
||||
if (cameraMove.sqrMagnitude > 0.1f)
|
||||
{
|
||||
HandleCameraMovement(cameraMove);
|
||||
}
|
||||
|
||||
float rotate = InputManager.Instance.CameraAction.Rotate.ReadValue<float>();
|
||||
if (rotate != 0)
|
||||
{
|
||||
HandleCameraRotation(rotate, _rotateSpeed);
|
||||
}
|
||||
//HandleCameraZoom_FOV();
|
||||
//HandleCameraZoom_MoveForward();
|
||||
HandleCameraZoom_MoveY();
|
||||
//HandleCameraZoom_MoveY();
|
||||
}
|
||||
|
||||
private void HandleCameraZoom_MoveForward()
|
||||
@@ -85,12 +108,11 @@ public class CameraSystem : MonoBehaviour
|
||||
_cinemachineTransposer.m_FollowOffset = _followOffset;
|
||||
}
|
||||
|
||||
private void HandleCameraZoom_MoveY()
|
||||
private void OnCameraZoom(InputAction.CallbackContext context)
|
||||
{
|
||||
if (Input.mouseScrollDelta.y > 0)
|
||||
_followOffset.y -= _zoomAmount;
|
||||
if (Input.mouseScrollDelta.y < 0)
|
||||
_followOffset.y += _zoomAmount;
|
||||
float _zoomAmount = InputManager.Instance.CameraAction.Rotate.ReadValue<float>();
|
||||
|
||||
_followOffset.y += _zoomAmount;
|
||||
|
||||
_followOffset.y = Mathf.Clamp(_followOffset.y, _followOffsetMinY, _followOffsetMaxY);
|
||||
|
||||
@@ -100,8 +122,6 @@ public class CameraSystem : MonoBehaviour
|
||||
if (_followOffset.magnitude > _followOffsetMax)
|
||||
_followOffset.y = _zoomAmount * _followOffsetMax;
|
||||
|
||||
|
||||
|
||||
Vector3.Lerp(_cinemachineTransposer.m_FollowOffset, _followOffset, Time.deltaTime * _zoomSpeed);
|
||||
|
||||
_cinemachineTransposer.m_FollowOffset = _followOffset;
|
||||
@@ -119,15 +139,8 @@ public class CameraSystem : MonoBehaviour
|
||||
_camera.m_Lens.FieldOfView = _targetFieldOfView;
|
||||
}
|
||||
|
||||
private void HandleCameraMovement()
|
||||
private void HandleCameraMovement(Vector2 inputDir)
|
||||
{
|
||||
var inputDir = Vector3.zero;
|
||||
|
||||
if (Input.GetKey(KeyCode.W)) inputDir.z = 1f;
|
||||
if (Input.GetKey(KeyCode.S)) inputDir.z = -1f;
|
||||
if (Input.GetKey(KeyCode.A)) inputDir.x = -1f;
|
||||
if (Input.GetKey(KeyCode.D)) inputDir.x = 1f;
|
||||
|
||||
if (_useEdgeScrolling)
|
||||
{
|
||||
inputDir = EdgeScrollingMovement(inputDir);
|
||||
@@ -137,27 +150,27 @@ public class CameraSystem : MonoBehaviour
|
||||
inputDir = MousePanMovement(inputDir);
|
||||
}
|
||||
|
||||
Vector3 moveDir = transform.forward * inputDir.z + transform.right * inputDir.x;
|
||||
Vector3 moveDir = transform.forward * inputDir.y + transform.right * inputDir.x;
|
||||
transform.position += moveDir * _moveSpeed * Time.deltaTime;
|
||||
}
|
||||
|
||||
private Vector3 MousePanMovement(Vector3 inputDir)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
_dragPanMoveActive = true;
|
||||
_lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
if (Input.GetMouseButtonUp(1)) { _dragPanMoveActive = false; }
|
||||
// if (Input.GetMouseButtonDown(1))
|
||||
// {
|
||||
// _dragPanMoveActive = true;
|
||||
// _lastMousePosition = Input.mousePosition;
|
||||
// }
|
||||
// if (Input.GetMouseButtonUp(1)) { _dragPanMoveActive = false; }
|
||||
|
||||
if (_dragPanMoveActive)
|
||||
{
|
||||
Vector2 mouseMovementDelta = ((Vector2)Input.mousePosition - _lastMousePosition) * _dragPanSpeed;
|
||||
inputDir.x = mouseMovementDelta.x;
|
||||
inputDir.z = mouseMovementDelta.y;
|
||||
// if (_dragPanMoveActive)
|
||||
// {
|
||||
// Vector2 mouseMovementDelta = ((Vector2)Input.mousePosition - _lastMousePosition) * _dragPanSpeed;
|
||||
// inputDir.x = mouseMovementDelta.x;
|
||||
// inputDir.z = mouseMovementDelta.y;
|
||||
|
||||
_lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
// _lastMousePosition = Input.mousePosition;
|
||||
// }
|
||||
|
||||
return inputDir;
|
||||
}
|
||||
@@ -171,29 +184,17 @@ public class CameraSystem : MonoBehaviour
|
||||
return inputDir;
|
||||
}
|
||||
|
||||
private void HandleCameraRotation()
|
||||
private void OnCameraRotate(InputAction.CallbackContext context)
|
||||
{
|
||||
float rotateDir = 0f;
|
||||
|
||||
if (Input.GetKey(KeyCode.E)) rotateDir = 1f;
|
||||
if (Input.GetKey(KeyCode.Q)) rotateDir = -1f;
|
||||
if (_useMouseRotate)
|
||||
if (!_useMouseRotate && !Mouse.current.middleButton.isPressed)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(2))
|
||||
{
|
||||
_dragRotateMoveActive = true;
|
||||
_lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
if (Input.GetMouseButtonUp(2)) { _dragRotateMoveActive = false; }
|
||||
if (_dragRotateMoveActive)
|
||||
{
|
||||
Vector2 mouseMovementDelta = ((Vector2)Input.mousePosition - _lastMousePosition);
|
||||
rotateDir = mouseMovementDelta.x;
|
||||
|
||||
_lastMousePosition = Input.mousePosition;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var speed = _dragRotateMoveActive ? _mouseRotationSpeed : _rotateSpeed;
|
||||
HandleCameraRotation(Mouse.current.delta.x.value, _mouseRotationSpeed);
|
||||
}
|
||||
|
||||
private void HandleCameraRotation(float rotateDir, float speed)
|
||||
{
|
||||
transform.eulerAngles += new Vector3(0, rotateDir * speed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+33
-24
@@ -2,7 +2,7 @@ using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class MouseInputManager : MonoBehaviour
|
||||
public class InGameMouseHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private LayerMask _selectableLayerMask;
|
||||
@@ -11,18 +11,40 @@ public class MouseInputManager : MonoBehaviour
|
||||
[SerializeField]
|
||||
private WaypointVisual _waypointVisual;
|
||||
|
||||
|
||||
public static event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
|
||||
|
||||
public static MouseInputManager Instance { get; private set; }
|
||||
private BaseInteractableObject _selectedObject;
|
||||
|
||||
private void Awake()
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (Instance != null)
|
||||
InputManager.Instance.PlayerAction.PointClick.performed += ClickToMove;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.Instance.PlayerAction.PointClick.performed += ClickToMove;
|
||||
}
|
||||
|
||||
private void ClickToMove(UnityEngine.InputSystem.InputAction.CallbackContext context)
|
||||
{
|
||||
if (!EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
Debug.Log("There's more than one mouse Input instance");
|
||||
if (_selectedObject != null)
|
||||
{
|
||||
print($"Go to interaction point {_selectedObject._interactionPoint.position}");
|
||||
_waypointVisual.SetWaypoint(_selectedObject._interactionPoint.position);
|
||||
Player.Instance.AddTask(new PlayerTasks(Tasks.Interact, _selectedObject));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100f, _walkableLayerMask))
|
||||
{
|
||||
_waypointVisual.SetWaypoint(hit.point);
|
||||
Player.Instance.AddTask(new PlayerTasks(Tasks.Move, _waypointVisual));
|
||||
}
|
||||
}
|
||||
}
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -35,16 +57,10 @@ public class MouseInputManager : MonoBehaviour
|
||||
//hide rounded menu
|
||||
if (Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
|
||||
{
|
||||
mouseRaycastHit.transform.TryGetComponent(out BaseInteractableObject baseObject);
|
||||
if (baseObject != null)
|
||||
mouseRaycastHit.transform.TryGetComponent(out _selectedObject);
|
||||
if (_selectedObject != null)
|
||||
{
|
||||
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = baseObject });
|
||||
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
print($"Go to interaction point {baseObject._interactionPoint.position}");
|
||||
_waypointVisual.SetWaypoint(baseObject._interactionPoint.position);
|
||||
Player.Instance.AddTask(new PlayerTasks(Tasks.Interact, baseObject));
|
||||
}
|
||||
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = _selectedObject });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,14 +70,7 @@ public class MouseInputManager : MonoBehaviour
|
||||
else
|
||||
{
|
||||
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = null });
|
||||
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, 100f, _walkableLayerMask))
|
||||
{
|
||||
_waypointVisual.SetWaypoint(hit.point);
|
||||
Player.Instance.AddTask(new PlayerTasks(Tasks.Move, _waypointVisual));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using static InputActions;
|
||||
|
||||
public class InputManager : MonoBehaviour
|
||||
{
|
||||
private InputActions _inputActions;
|
||||
public static InputManager Instance { get; private set; }
|
||||
|
||||
public PlayerActions PlayerAction { get; private set; }
|
||||
public CameraActions CameraAction { get; private set; }
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null)
|
||||
{
|
||||
Debug.Log("There's more than one Input manager instance");
|
||||
}
|
||||
Instance = this;
|
||||
|
||||
_inputActions = new InputActions();
|
||||
|
||||
PlayerAction = _inputActions.Player;
|
||||
CameraAction = _inputActions.Camera;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_inputActions.Enable();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
_inputActions.Disable();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d53c0360fd8463a4b9481cbbaaf6da7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d8db829ce926f54dbebc240dee2c205
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,426 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.7.0
|
||||
// from Assets/Scripts/Managers/InputSystem/InputActions.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
{
|
||||
public InputActionAsset asset { get; }
|
||||
public @InputActions()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""name"": ""InputActions"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""Player"",
|
||||
""id"": ""277864dc-d6c8-485b-860f-70382a4eaa1e"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""PointClick"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""fb720cef-8db9-45ea-94b8-34ee20907014"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""105098b7-cb9c-4bea-a128-25fb122efd3d"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""PointClick"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Camera"",
|
||||
""id"": ""9f9ddc51-3eac-495d-9e72-48577c8c8f4b"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Move"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""42ed90e2-8e04-4002-a0a1-953fae8787ce"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Rotate"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""d269ae49-9dbe-4e7c-9a80-1276e29898d8"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Zoom"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""41d86dbc-39e0-4655-bc19-0eab9d5014a6"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""MouseRotate"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""646b1fc6-f255-4d12-927e-de1a93611e1b"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": ""WASD"",
|
||||
""id"": ""6a0891b5-2eec-48ad-850d-8f3d4589816b"",
|
||||
""path"": ""2DVector"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""up"",
|
||||
""id"": ""2e6af5dd-f093-4f51-8df7-996b3d0b7d8e"",
|
||||
""path"": ""<Keyboard>/w"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""down"",
|
||||
""id"": ""ef522e93-330b-4a04-8be5-9d719c461129"",
|
||||
""path"": ""<Keyboard>/s"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""left"",
|
||||
""id"": ""4785db1d-a198-4f1b-a4a3-15825b7301fd"",
|
||||
""path"": ""<Keyboard>/a"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""right"",
|
||||
""id"": ""8fdeb47b-06d1-4535-9742-01aacdd7d7a1"",
|
||||
""path"": ""<Keyboard>/d"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""4c934323-993d-4354-8897-20bcd2f9dddc"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Rotate"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Negative"",
|
||||
""id"": ""6f9e4496-b244-4667-8720-9096c41e3b4a"",
|
||||
""path"": ""<Keyboard>/e"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Rotate"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Positive"",
|
||||
""id"": ""a89182c9-b935-4450-94e4-6d630806f6cc"",
|
||||
""path"": ""<Keyboard>/q"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Rotate"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""c813ebc8-78b7-4e4d-8340-564c7231e367"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Zoom"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""6bc3cbff-c850-49b7-bb63-6d49712aa2b7"",
|
||||
""path"": ""<Mouse>/scroll/down"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Zoom"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""d1a58c3b-b104-4c55-ab6f-faaf03b9b5c5"",
|
||||
""path"": ""<Mouse>/scroll/up"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Zoom"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""e84dc7e3-3c1e-4bb9-af62-e3ef4261fbbc"",
|
||||
""path"": ""<Mouse>/middleButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MouseRotate"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": []
|
||||
}");
|
||||
// Player
|
||||
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
|
||||
m_Player_PointClick = m_Player.FindAction("PointClick", throwIfNotFound: true);
|
||||
// Camera
|
||||
m_Camera = asset.FindActionMap("Camera", throwIfNotFound: true);
|
||||
m_Camera_Move = m_Camera.FindAction("Move", throwIfNotFound: true);
|
||||
m_Camera_Rotate = m_Camera.FindAction("Rotate", throwIfNotFound: true);
|
||||
m_Camera_Zoom = m_Camera.FindAction("Zoom", throwIfNotFound: true);
|
||||
m_Camera_MouseRotate = m_Camera.FindAction("MouseRotate", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// Player
|
||||
private readonly InputActionMap m_Player;
|
||||
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
|
||||
private readonly InputAction m_Player_PointClick;
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @InputActions m_Wrapper;
|
||||
public PlayerActions(@InputActions wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @PointClick => m_Wrapper.m_Player_PointClick;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Add(instance);
|
||||
@PointClick.started += instance.OnPointClick;
|
||||
@PointClick.performed += instance.OnPointClick;
|
||||
@PointClick.canceled += instance.OnPointClick;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IPlayerActions instance)
|
||||
{
|
||||
@PointClick.started -= instance.OnPointClick;
|
||||
@PointClick.performed -= instance.OnPointClick;
|
||||
@PointClick.canceled -= instance.OnPointClick;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IPlayerActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public PlayerActions @Player => new PlayerActions(this);
|
||||
|
||||
// Camera
|
||||
private readonly InputActionMap m_Camera;
|
||||
private List<ICameraActions> m_CameraActionsCallbackInterfaces = new List<ICameraActions>();
|
||||
private readonly InputAction m_Camera_Move;
|
||||
private readonly InputAction m_Camera_Rotate;
|
||||
private readonly InputAction m_Camera_Zoom;
|
||||
private readonly InputAction m_Camera_MouseRotate;
|
||||
public struct CameraActions
|
||||
{
|
||||
private @InputActions m_Wrapper;
|
||||
public CameraActions(@InputActions wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Move => m_Wrapper.m_Camera_Move;
|
||||
public InputAction @Rotate => m_Wrapper.m_Camera_Rotate;
|
||||
public InputAction @Zoom => m_Wrapper.m_Camera_Zoom;
|
||||
public InputAction @MouseRotate => m_Wrapper.m_Camera_MouseRotate;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Camera; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(CameraActions set) { return set.Get(); }
|
||||
public void AddCallbacks(ICameraActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_CameraActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_CameraActionsCallbackInterfaces.Add(instance);
|
||||
@Move.started += instance.OnMove;
|
||||
@Move.performed += instance.OnMove;
|
||||
@Move.canceled += instance.OnMove;
|
||||
@Rotate.started += instance.OnRotate;
|
||||
@Rotate.performed += instance.OnRotate;
|
||||
@Rotate.canceled += instance.OnRotate;
|
||||
@Zoom.started += instance.OnZoom;
|
||||
@Zoom.performed += instance.OnZoom;
|
||||
@Zoom.canceled += instance.OnZoom;
|
||||
@MouseRotate.started += instance.OnMouseRotate;
|
||||
@MouseRotate.performed += instance.OnMouseRotate;
|
||||
@MouseRotate.canceled += instance.OnMouseRotate;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(ICameraActions instance)
|
||||
{
|
||||
@Move.started -= instance.OnMove;
|
||||
@Move.performed -= instance.OnMove;
|
||||
@Move.canceled -= instance.OnMove;
|
||||
@Rotate.started -= instance.OnRotate;
|
||||
@Rotate.performed -= instance.OnRotate;
|
||||
@Rotate.canceled -= instance.OnRotate;
|
||||
@Zoom.started -= instance.OnZoom;
|
||||
@Zoom.performed -= instance.OnZoom;
|
||||
@Zoom.canceled -= instance.OnZoom;
|
||||
@MouseRotate.started -= instance.OnMouseRotate;
|
||||
@MouseRotate.performed -= instance.OnMouseRotate;
|
||||
@MouseRotate.canceled -= instance.OnMouseRotate;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(ICameraActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_CameraActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(ICameraActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_CameraActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_CameraActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public CameraActions @Camera => new CameraActions(this);
|
||||
public interface IPlayerActions
|
||||
{
|
||||
void OnPointClick(InputAction.CallbackContext context);
|
||||
}
|
||||
public interface ICameraActions
|
||||
{
|
||||
void OnMove(InputAction.CallbackContext context);
|
||||
void OnRotate(InputAction.CallbackContext context);
|
||||
void OnZoom(InputAction.CallbackContext context);
|
||||
void OnMouseRotate(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ee03839176db9042b88621fd5020b18
|
||||
@@ -0,0 +1,210 @@
|
||||
{
|
||||
"name": "InputActions",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Player",
|
||||
"id": "277864dc-d6c8-485b-860f-70382a4eaa1e",
|
||||
"actions": [
|
||||
{
|
||||
"name": "PointClick",
|
||||
"type": "Button",
|
||||
"id": "fb720cef-8db9-45ea-94b8-34ee20907014",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "105098b7-cb9c-4bea-a128-25fb122efd3d",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "PointClick",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Camera",
|
||||
"id": "9f9ddc51-3eac-495d-9e72-48577c8c8f4b",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Move",
|
||||
"type": "Value",
|
||||
"id": "42ed90e2-8e04-4002-a0a1-953fae8787ce",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Rotate",
|
||||
"type": "Value",
|
||||
"id": "d269ae49-9dbe-4e7c-9a80-1276e29898d8",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Zoom",
|
||||
"type": "Value",
|
||||
"id": "41d86dbc-39e0-4655-bc19-0eab9d5014a6",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "MouseRotate",
|
||||
"type": "Button",
|
||||
"id": "646b1fc6-f255-4d12-927e-de1a93611e1b",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "WASD",
|
||||
"id": "6a0891b5-2eec-48ad-850d-8f3d4589816b",
|
||||
"path": "2DVector",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "up",
|
||||
"id": "2e6af5dd-f093-4f51-8df7-996b3d0b7d8e",
|
||||
"path": "<Keyboard>/w",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "down",
|
||||
"id": "ef522e93-330b-4a04-8be5-9d719c461129",
|
||||
"path": "<Keyboard>/s",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "left",
|
||||
"id": "4785db1d-a198-4f1b-a4a3-15825b7301fd",
|
||||
"path": "<Keyboard>/a",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "right",
|
||||
"id": "8fdeb47b-06d1-4535-9742-01aacdd7d7a1",
|
||||
"path": "<Keyboard>/d",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "4c934323-993d-4354-8897-20bcd2f9dddc",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Rotate",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "Negative",
|
||||
"id": "6f9e4496-b244-4667-8720-9096c41e3b4a",
|
||||
"path": "<Keyboard>/e",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Rotate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "Positive",
|
||||
"id": "a89182c9-b935-4450-94e4-6d630806f6cc",
|
||||
"path": "<Keyboard>/q",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Rotate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "c813ebc8-78b7-4e4d-8340-564c7231e367",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Zoom",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "6bc3cbff-c850-49b7-bb63-6d49712aa2b7",
|
||||
"path": "<Mouse>/scroll/down",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Zoom",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "d1a58c3b-b104-4c55-ab6f-faaf03b9b5c5",
|
||||
"path": "<Mouse>/scroll/up",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Zoom",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "e84dc7e3-3c1e-4bb9-af62-e3ef4261fbbc",
|
||||
"path": "<Mouse>/middleButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseRotate",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 728db966a1cb6454eb419e9cc8cfaf70
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
Reference in New Issue
Block a user