| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using Cinemachine; |
| | 5 | | using DCL.Camera; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | public class OverrideCinemachineAxisInput : MonoBehaviour |
| | 9 | | { |
| | 10 | |
|
| | 11 | | [Serializable] |
| | 12 | | public struct AxisToMeasurableAction |
| | 13 | | { |
| | 14 | | public string axisName; |
| | 15 | | public InputAction_Measurable measurableAction; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | [SerializeField] private AxisToMeasurableAction[] axisToMeasurableActions; |
| | 19 | | private Dictionary<string, InputAction_Measurable> cachedAxisToMeasurableActions; |
| | 20 | | private InputSpikeFixer inputSpikeFixer; |
| | 21 | |
|
| | 22 | | private void Awake() |
| | 23 | | { |
| 620 | 24 | | cachedAxisToMeasurableActions = axisToMeasurableActions.ToDictionary(x => x.axisName, x => x.measurableAction); |
| 124 | 25 | | CinemachineCore.GetInputAxis = OverrideGetAxis; |
| 21154 | 26 | | inputSpikeFixer = new InputSpikeFixer(() => Cursor.lockState); |
| 124 | 27 | | } |
| | 28 | |
|
| | 29 | | private float OverrideGetAxis(string axisName) |
| | 30 | | { |
| 20906 | 31 | | if (!cachedAxisToMeasurableActions.ContainsKey(axisName)) |
| 0 | 32 | | return 0; |
| | 33 | |
|
| 20906 | 34 | | float value = cachedAxisToMeasurableActions[axisName].GetValue(); |
| 20906 | 35 | | return inputSpikeFixer.GetValue(value); |
| | 36 | | } |
| | 37 | |
|
| | 38 | | } |