| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using Cinemachine; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | public class OverrideCinemachineAxisInput : MonoBehaviour |
| | 8 | | { |
| | 9 | | [Serializable] |
| | 10 | | public struct AxisToMeasurableAction |
| | 11 | | { |
| | 12 | | public string axisName; |
| | 13 | | public InputAction_Measurable measurableAction; |
| | 14 | | } |
| | 15 | |
|
| | 16 | | [SerializeField] private AxisToMeasurableAction[] axisToMeasurableActions; |
| | 17 | | private Dictionary<string, InputAction_Measurable> cachedAxisToMeasurableActions; |
| | 18 | |
|
| | 19 | | private void Awake() |
| | 20 | | { |
| 625 | 21 | | cachedAxisToMeasurableActions = axisToMeasurableActions.ToDictionary(x => x.axisName, x => x.measurableAction); |
| 125 | 22 | | CinemachineCore.GetInputAxis = OverrideGetAxis; |
| 125 | 23 | | } |
| | 24 | |
|
| | 25 | | private float OverrideGetAxis(string axisName) |
| | 26 | | { |
| 31306 | 27 | | if (!cachedAxisToMeasurableActions.ContainsKey(axisName)) |
| 0 | 28 | | return 0; |
| | 29 | |
|
| 31306 | 30 | | return cachedAxisToMeasurableActions[axisName].GetValue(); |
| | 31 | | } |
| | 32 | | } |