Skip to content

Commit 521490d

Browse files
glabutegaborkb
authored andcommitted
Backport: add auto-enable option to input handler (#424)
1 parent 8a50f09 commit 521490d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
- Timeline guards added to scripts that rely on it.
1212
- Bugfix: CinemachineInputProvider now correctly tracks enabled state of input action
1313
- Bugfix: POV orientation was incorrect with World Up override
14+
- Added AutoEnable option to CinemachineInputHandler
1415

1516

1617
## [2.6.11] - 2021-10-05

Runtime/Helpers/CinemachineInputProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public class CinemachineInputProvider : MonoBehaviour, AxisState.IInputAxisProvi
2424
+ "be read from that player's controls")]
2525
public int PlayerIndex = -1;
2626

27+
/// <summary>If set, Input Actions will be auto-enabled at start</summary>
28+
[Tooltip("If set, Input Actions will be auto-enabled at start")]
29+
public bool AutoEnableInputs = true;
30+
2731
/// <summary>Vector2 action for XY movement</summary>
2832
[Tooltip("Vector2 action for XY movement")]
2933
public InputActionReference XYAxis;
@@ -81,10 +85,10 @@ protected InputAction ResolveForPlayer(int axis, InputActionReference actionRef)
8185
{
8286
m_cachedActions[axis] = actionRef.action;
8387
if (PlayerIndex != -1)
84-
{
85-
var user = InputUser.all[PlayerIndex];
86-
m_cachedActions[axis] = user.actions.First(x => x.id == actionRef.action.id);
87-
}
88+
m_cachedActions[axis] = GetFirstMatch(InputUser.all[PlayerIndex], actionRef);
89+
90+
if (AutoEnableInputs && actionRef != null && actionRef.action != null)
91+
actionRef.action.Enable();
8892
}
8993

9094
// Update enabled status

0 commit comments

Comments
 (0)