Skip to content

Commit 1ba9dba

Browse files
committed
Temporarily disabled new function of suppressing non-matched input, it might not be needed. Added proper UI disable state to RebindMenu since RebindOverlay is essentially another "window" grabbing input context. Hence the sample should behave like this since its the most correct way instead of suppressing UI input.
1 parent b5272cd commit 1ba9dba

File tree

6 files changed

+71
-6
lines changed

6 files changed

+71
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace UnityEngine.InputSystem.Samples.RebindUI
2+
{
3+
/// <summary>
4+
/// Simple utility that modifies a referenced CanvasGroup while being active.
5+
/// </summary>
6+
public class CanvasGroupModifier : MonoBehaviour
7+
{
8+
[Tooltip("The Canvas Group to be modified while this component is active")]
9+
public CanvasGroup canvasGroup;
10+
11+
[Tooltip("The interactable setting to use for the Canvas Group while this component is active")]
12+
public bool interactable = false;
13+
14+
private bool m_SavedInteractable;
15+
16+
void OnEnable()
17+
{
18+
if (canvasGroup != null)
19+
{
20+
// Save current setting and override
21+
m_SavedInteractable = canvasGroup.interactable;
22+
canvasGroup.interactable = interactable;
23+
}
24+
}
25+
26+
void OnDisable()
27+
{
28+
if (canvasGroup != null)
29+
{
30+
// Restore previous setting
31+
canvasGroup.interactable = m_SavedInteractable;
32+
}
33+
}
34+
}
35+
}

Assets/Samples/RebindingUI/CanvasGroupModifier.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Samples/RebindingUI/RebindActionUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ void CleanUp()
305305
CleanUp();
306306
})
307307
// We want matching events to be suppressed during rebinding (this is also default).
308-
.WithMatchingEventsBeingSuppressed()
308+
//.WithMatchingEventsBeingSuppressed()
309309
// Since this sample has no interactable UI during rebinding we also want to suppress non-matching events.
310-
.WithNonMatchingEventsBeingSuppressed()
310+
//.WithNonMatchingEventsBeingSuppressed()
311311
// We want device state to update but not actions firing during rebinding.
312312
.WithActionsBeingSuppressed()
313313
// Since this sample has no UI to cancle rebinding we timeout after not receiving input for a period of time.

Assets/Samples/RebindingUI/RebindUIPrefab.prefab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ MonoBehaviour:
102102
m_HighlightedColor: {r: 0.36173913, g: 0.4408696, b: 0.65, a: 1}
103103
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
104104
m_SelectedColor: {r: 0.8679245, g: 0.4550042, b: 0.045033824, a: 1}
105-
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
105+
m_DisabledColor: {r: 0.21960784, g: 0.21960784, b: 0.25882354, a: 1}
106106
m_ColorMultiplier: 1
107107
m_FadeDuration: 0.1
108108
m_SpriteState:
@@ -389,7 +389,7 @@ MonoBehaviour:
389389
m_BindingText: {fileID: 690190895482579582}
390390
m_RebindOverlay: {fileID: 0}
391391
m_RebindText: {fileID: 0}
392-
m_DefaultInputActions: {fileID: 0}
392+
m_RebindInfo: {fileID: 0}
393393
m_UpdateBindingUIEvent:
394394
m_PersistentCalls:
395395
m_Calls: []
@@ -580,7 +580,7 @@ MonoBehaviour:
580580
m_HighlightedColor: {r: 0.36078432, g: 0.4392157, b: 0.6509804, a: 1}
581581
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
582582
m_SelectedColor: {r: 0.8666667, g: 0.45490196, b: 0.043137256, a: 1}
583-
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
583+
m_DisabledColor: {r: 0.22, g: 0.22, b: 0.25882354, a: 1}
584584
m_ColorMultiplier: 1
585585
m_FadeDuration: 0.1
586586
m_SpriteState:

Assets/Samples/RebindingUI/RebindingUISampleScene.unity

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,7 @@ GameObject:
16221622
- component: {fileID: 508436408}
16231623
- component: {fileID: 508436407}
16241624
- component: {fileID: 508436409}
1625+
- component: {fileID: 508436410}
16251626
m_Layer: 5
16261627
m_Name: RebindMenu
16271628
m_TagString: Untagged
@@ -1717,6 +1718,18 @@ MonoBehaviour:
17171718
m_StringArgument:
17181719
m_BoolArgument: 0
17191720
m_CallState: 2
1721+
--- !u!225 &508436410
1722+
CanvasGroup:
1723+
m_ObjectHideFlags: 0
1724+
m_CorrespondingSourceObject: {fileID: 0}
1725+
m_PrefabInstance: {fileID: 0}
1726+
m_PrefabAsset: {fileID: 0}
1727+
m_GameObject: {fileID: 508436405}
1728+
m_Enabled: 1
1729+
m_Alpha: 1
1730+
m_Interactable: 1
1731+
m_BlocksRaycasts: 1
1732+
m_IgnoreParentGroups: 0
17201733
--- !u!224 &510051365 stripped
17211734
RectTransform:
17221735
m_CorrespondingSourceObject: {fileID: 1777307397533242038, guid: 0648a5c163cef41038b804a34b4b80e7,
@@ -3994,6 +4007,7 @@ GameObject:
39944007
- component: {fileID: 1106689462}
39954008
- component: {fileID: 1106689464}
39964009
- component: {fileID: 1106689463}
4010+
- component: {fileID: 1106689465}
39974011
m_Layer: 5
39984012
m_Name: RebindOverlay
39994013
m_TagString: Untagged
@@ -4060,6 +4074,20 @@ CanvasRenderer:
40604074
m_PrefabAsset: {fileID: 0}
40614075
m_GameObject: {fileID: 1106689461}
40624076
m_CullTransparentMesh: 0
4077+
--- !u!114 &1106689465
4078+
MonoBehaviour:
4079+
m_ObjectHideFlags: 0
4080+
m_CorrespondingSourceObject: {fileID: 0}
4081+
m_PrefabInstance: {fileID: 0}
4082+
m_PrefabAsset: {fileID: 0}
4083+
m_GameObject: {fileID: 1106689461}
4084+
m_Enabled: 1
4085+
m_EditorHideFlags: 0
4086+
m_Script: {fileID: 11500000, guid: f694bb5379aca43c790706ceb4191b31, type: 3}
4087+
m_Name:
4088+
m_EditorClassIdentifier:
4089+
canvasGroup: {fileID: 508436410}
4090+
interactable: 0
40634091
--- !u!1 &1121800141
40644092
GameObject:
40654093
m_ObjectHideFlags: 0

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionRebindingExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ public RebindingOperation OnMatchWaitForAnother(float seconds)
21382138
public RebindingOperation WithActionsBeingSuppressed(bool value = true)
21392139
{
21402140
ThrowIfRebindInProgress();
2141-
m_TargetInputEventHandledPolicy = value
2141+
m_TargetInputEventHandledPolicy = value
21422142
? InputEventHandledPolicy.SuppressActionUpdates
21432143
: InputEventHandledPolicy.SuppressStateUpdates;
21442144
return this;

0 commit comments

Comments
 (0)