diff --git a/Assets/BlenderModels/road.blend b/Assets/BlenderModels/road.blend index f114deb0..8062ab5c 100644 Binary files a/Assets/BlenderModels/road.blend and b/Assets/BlenderModels/road.blend differ diff --git a/Assets/BlenderModels/road.blend1 b/Assets/BlenderModels/road.blend1 index b91daa9d..f114deb0 100644 Binary files a/Assets/BlenderModels/road.blend1 and b/Assets/BlenderModels/road.blend1 differ diff --git a/Assets/Scenes/City_new.unity b/Assets/Scenes/City_new.unity index 4e716204..0e7f1755 100644 --- a/Assets/Scenes/City_new.unity +++ b/Assets/Scenes/City_new.unity @@ -1383,9 +1383,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 349281313} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 250, y: -90} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 250, y: 0} m_SizeDelta: {x: 480, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &249161732 @@ -5409,6 +5409,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1492792594} + - component: {fileID: 1492792595} m_Layer: 0 m_Name: Managers m_TagString: Untagged @@ -5433,6 +5434,18 @@ Transform: - {fileID: 1832218964} m_Father: {fileID: 495189437} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1492792595 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1492792593} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d53c0360fd8463a4b9481cbbaaf6da7a, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1498687847 GameObject: m_ObjectHideFlags: 0 @@ -11283,7 +11296,7 @@ GameObject: - component: {fileID: 1832218964} - component: {fileID: 1832218965} m_Layer: 6 - m_Name: MouseInputManager + m_Name: InGameMouseHandler m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/Scripts/InteractableObjects/SelectedVisual.cs b/Assets/Scripts/InteractableObjects/SelectedVisual.cs index 3386f71a..dd0a39f3 100644 --- a/Assets/Scripts/InteractableObjects/SelectedVisual.cs +++ b/Assets/Scripts/InteractableObjects/SelectedVisual.cs @@ -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"); } diff --git a/Assets/Scripts/New Lighting Settings.lighting b/Assets/Scripts/Lighting Settings.lighting similarity index 98% rename from Assets/Scripts/New Lighting Settings.lighting rename to Assets/Scripts/Lighting Settings.lighting index 45c08ed6..df8b10b4 100644 --- a/Assets/Scripts/New Lighting Settings.lighting +++ b/Assets/Scripts/Lighting Settings.lighting @@ -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 diff --git a/Assets/Scripts/New Lighting Settings.lighting.meta b/Assets/Scripts/Lighting Settings.lighting.meta similarity index 100% rename from Assets/Scripts/New Lighting Settings.lighting.meta rename to Assets/Scripts/Lighting Settings.lighting.meta diff --git a/Assets/Scripts/Managers/CameraSystem.cs b/Assets/Scripts/Managers/CameraSystem.cs index a439494c..6b270190 100644 --- a/Assets/Scripts/Managers/CameraSystem.cs +++ b/Assets/Scripts/Managers/CameraSystem.cs @@ -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(); + if (cameraMove.sqrMagnitude > 0.1f) + { + HandleCameraMovement(cameraMove); + } + + float rotate = InputManager.Instance.CameraAction.Rotate.ReadValue(); + 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(); + + _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); } } diff --git a/Assets/Scripts/Managers/MouseInputManager.cs b/Assets/Scripts/Managers/InGameMouseHandler.cs similarity index 53% rename from Assets/Scripts/Managers/MouseInputManager.cs rename to Assets/Scripts/Managers/InGameMouseHandler.cs index 77fc5b38..bdc46040 100644 --- a/Assets/Scripts/Managers/MouseInputManager.cs +++ b/Assets/Scripts/Managers/InGameMouseHandler.cs @@ -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 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)); - } - } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Managers/MouseInputManager.cs.meta b/Assets/Scripts/Managers/InGameMouseHandler.cs.meta similarity index 100% rename from Assets/Scripts/Managers/MouseInputManager.cs.meta rename to Assets/Scripts/Managers/InGameMouseHandler.cs.meta diff --git a/Assets/Scripts/Managers/InputManager.cs b/Assets/Scripts/Managers/InputManager.cs new file mode 100644 index 00000000..8e0a83db --- /dev/null +++ b/Assets/Scripts/Managers/InputManager.cs @@ -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(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Managers/InputManager.cs.meta b/Assets/Scripts/Managers/InputManager.cs.meta new file mode 100644 index 00000000..ec607610 --- /dev/null +++ b/Assets/Scripts/Managers/InputManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d53c0360fd8463a4b9481cbbaaf6da7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers/InputSystem.meta b/Assets/Scripts/Managers/InputSystem.meta new file mode 100644 index 00000000..4c2dd058 --- /dev/null +++ b/Assets/Scripts/Managers/InputSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d8db829ce926f54dbebc240dee2c205 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.cs b/Assets/Scripts/Managers/InputSystem/InputActions.cs new file mode 100644 index 00000000..23dd6f94 --- /dev/null +++ b/Assets/Scripts/Managers/InputSystem/InputActions.cs @@ -0,0 +1,426 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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"": ""/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"": ""/w"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""down"", + ""id"": ""ef522e93-330b-4a04-8be5-9d719c461129"", + ""path"": ""/s"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""left"", + ""id"": ""4785db1d-a198-4f1b-a4a3-15825b7301fd"", + ""path"": ""/a"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""right"", + ""id"": ""8fdeb47b-06d1-4535-9742-01aacdd7d7a1"", + ""path"": ""/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"": ""/e"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Rotate"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""Positive"", + ""id"": ""a89182c9-b935-4450-94e4-6d630806f6cc"", + ""path"": ""/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"": ""/scroll/down"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Zoom"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""positive"", + ""id"": ""d1a58c3b-b104-4c55-ab6f-faaf03b9b5c5"", + ""path"": ""/scroll/up"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Zoom"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": """", + ""id"": ""e84dc7e3-3c1e-4bb9-af62-e3ef4261fbbc"", + ""path"": ""/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? devices + { + get => asset.devices; + set => asset.devices = value; + } + + public ReadOnlyArray controlSchemes => asset.controlSchemes; + + public bool Contains(InputAction action) + { + return asset.Contains(action); + } + + public IEnumerator GetEnumerator() + { + return asset.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Enable() + { + asset.Enable(); + } + + public void Disable() + { + asset.Disable(); + } + + public IEnumerable 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 m_PlayerActionsCallbackInterfaces = new List(); + 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 m_CameraActionsCallbackInterfaces = new List(); + 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); + } +} diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.cs.meta b/Assets/Scripts/Managers/InputSystem/InputActions.cs.meta new file mode 100644 index 00000000..5e4992af --- /dev/null +++ b/Assets/Scripts/Managers/InputSystem/InputActions.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8ee03839176db9042b88621fd5020b18 \ No newline at end of file diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.inputactions b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions new file mode 100644 index 00000000..2e0a4418 --- /dev/null +++ b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions @@ -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": "/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": "/w", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "ef522e93-330b-4a04-8be5-9d719c461129", + "path": "/s", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "4785db1d-a198-4f1b-a4a3-15825b7301fd", + "path": "/a", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "8fdeb47b-06d1-4535-9742-01aacdd7d7a1", + "path": "/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": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "Rotate", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "Positive", + "id": "a89182c9-b935-4450-94e4-6d630806f6cc", + "path": "/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": "/scroll/down", + "interactions": "", + "processors": "", + "groups": "", + "action": "Zoom", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "positive", + "id": "d1a58c3b-b104-4c55-ab6f-faaf03b9b5c5", + "path": "/scroll/up", + "interactions": "", + "processors": "", + "groups": "", + "action": "Zoom", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "e84dc7e3-3c1e-4bb9-af62-e3ef4261fbbc", + "path": "/middleButton", + "interactions": "", + "processors": "", + "groups": "", + "action": "MouseRotate", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [] +} \ No newline at end of file diff --git a/Assets/Scripts/Managers/InputSystem/InputActions.inputactions.meta b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions.meta new file mode 100644 index 00000000..ee591a6e --- /dev/null +++ b/Assets/Scripts/Managers/InputSystem/InputActions.inputactions.meta @@ -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: diff --git a/Packages/manifest.json b/Packages/manifest.json index 91e9ba2c..dac3f303 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -6,6 +6,7 @@ "com.unity.collab-proxy": "2.2.0", "com.unity.formats.fbx": "5.1.0", "com.unity.ide.visualstudio": "2.0.22", + "com.unity.inputsystem": "1.7.0", "com.unity.render-pipelines.universal": "16.0.4", "com.unity.test-framework": "1.3.9", "com.unity.timeline": "1.8.6", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 899fffd9..40fe1555 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -88,6 +88,15 @@ }, "url": "https://packages.unity.com" }, + "com.unity.inputsystem": { + "version": "1.7.0", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.uielements": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.mathematics": { "version": "1.2.6", "depth": 1, diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 7755d65b..4eeb290c 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 25 + serializedVersion: 27 productGUID: 9af30a73ab00cc24fad17a0f7dcf8b81 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -48,6 +48,7 @@ PlayerSettings: defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 m_ActiveColorSpace: 1 + unsupportedMSAAFallback: 0 m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 mipStripping: 0 @@ -75,6 +76,7 @@ PlayerSettings: androidMinimumWindowWidth: 400 androidMinimumWindowHeight: 300 androidFullscreenMode: 1 + androidApplicationEntry: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 0 @@ -86,6 +88,7 @@ PlayerSettings: hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 + dedicatedServerOptimizations: 0 bakeCollisionMeshes: 0 forceSingleInstance: 0 useFlipModelSwapchain: 1 @@ -93,6 +96,7 @@ PlayerSettings: useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 0 + meshDeformation: 0 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -124,9 +128,8 @@ PlayerSettings: switchAllowGpuScratchShrinking: 0 switchNVNMaxPublicTextureIDCount: 0 switchNVNMaxPublicSamplerIDCount: 0 + switchMaxWorkerMultiple: 8 switchNVNGraphicsFirmwareMemory: 32 - stadiaPresentMode: 0 - stadiaTargetFramerate: 0 vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 vulkanEnablePreTransform: 0 @@ -145,23 +148,26 @@ PlayerSettings: isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 enableOpenGLProfilerGPURecorders: 1 + allowHDRDisplaySupport: 0 useHDRDisplay: 0 - D3DHDRBitDepth: 0 + hdrBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 + androidMinAspectRatio: 1 applicationIdentifier: Standalone: com.UnityTechnologies.com.unity.template-starter-kit buildNumber: + Bratwurst: 0 Standalone: 0 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 1 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 22 + AndroidMinSdkVersion: 23 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -171,16 +177,18 @@ PlayerSettings: ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 - APKExpansionFiles: 0 + androidSplitApplicationBinary: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 strictShaderVariantMatching: 0 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 12.0 + iOSTargetOSVersionString: 13.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 12.0 + tvOSTargetOSVersionString: 13.0 + bratwurstSdkVersion: 0 + bratwurstTargetOSVersionString: 13.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 @@ -228,8 +236,10 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + bratwurstManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 + bratwurstManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 @@ -244,6 +254,7 @@ PlayerSettings: useCustomLauncherGradleManifest: 0 useCustomBaseGradleTemplate: 0 useCustomGradlePropertiesTemplate: 0 + useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 AndroidTargetArchitectures: 1 AndroidTargetDevices: 0 @@ -252,6 +263,7 @@ PlayerSettings: AndroidKeystoreName: AndroidKeyaliasName: AndroidEnableArmv9SecurityFeatures: 0 + AndroidEnableArm64MTE: 0 AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 0 AndroidIsGame: 1 @@ -269,6 +281,7 @@ PlayerSettings: AndroidMinifyDebug: 0 AndroidValidateAppBundleSize: 1 AndroidAppBundleSizeToValidate: 150 + AndroidReportGooglePlayAppDependencies: 1 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: - m_BuildTarget: iPhone @@ -506,7 +519,7 @@ PlayerSettings: m_APIs: 10000000 m_Automatic: 1 - m_BuildTarget: AndroidPlayer - m_APIs: 0b00000008000000 + m_APIs: 0b000000 m_Automatic: 0 m_BuildTargetVRSettings: [] m_DefaultShaderChunkSizeInMB: 16 @@ -543,7 +556,7 @@ PlayerSettings: switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 - switchUseGOLDLinker: 0 + switchEnableFileSystemTrace: 0 switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: @@ -621,7 +634,6 @@ PlayerSettings: switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 switchStartupUserAccount: 0 - switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 switchApplicationErrorCodeCategory: @@ -663,6 +675,7 @@ PlayerSettings: switchNativeFsCacheSize: 32 switchIsHoldTypeHorizontal: 0 switchSupportedNpadCount: 8 + switchEnableTouchScreen: 1 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -673,7 +686,7 @@ PlayerSettings: switchSocketBufferEfficiency: 4 switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 + switchDisableHTCSPlayerConnection: 0 switchUseNewStyleFilepaths: 0 switchUseLegacyFmodPriorities: 0 switchUseMicroSleepForYield: 1 @@ -782,24 +795,30 @@ PlayerSettings: webGLMemoryLinearGrowthStep: 16 webGLMemoryGeometricGrowthStep: 0.2 webGLMemoryGeometricGrowthCap: 96 + webGLEnableWebGPU: 0 webGLPowerPreference: 2 + webGLWebAssemblyTable: 0 + webGLWebAssemblyBigInt: 0 + webGLCloseOnQuit: 0 scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Android: 0 il2cppCompilerConfiguration: {} il2cppCodeGeneration: {} + il2cppStacktraceInformation: {} managedStrippingLevel: {} incrementalIl2cppBuild: {} suppressCommonWarnings: 1 allowUnsafeCode: 0 useDeterministicCompilation: 1 - selectedPlatform: 0 additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 0 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} + editorAssembliesCompatibilityLevel: 1 m_RenderingPath: 1 m_MobileRenderingPath: 1 metroPackageName: SimUL @@ -873,10 +892,12 @@ PlayerSettings: hmiPlayerDataPath: hmiForceSRGBBlit: 1 embeddedLinuxEnableGamepadInput: 1 - hmiLogStartupTiming: 0 hmiCpuConfiguration: + hmiLogStartupTiming: 0 + qnxGraphicConfPath: apiCompatibilityLevel: 6 - activeInputHandler: 0 + captureStartupLogs: {} + activeInputHandler: 2 windowsGamepadBackendHint: 0 cloudProjectId: framebufferDepthMemorylessMode: 0 @@ -886,5 +907,6 @@ PlayerSettings: cloudEnabled: 0 legacyClampBlendShapeWeights: 0 hmiLoadingImage: {fileID: 0} + platformRequiresReadableAssets: 0 virtualTexturingSupportEnabled: 0 insecureHttpOption: 0