Skip to content

Commit 2bd9307

Browse files
authored
implemented indicating bindings not included into the current control scheme (#1721)
1 parent d1c66c3 commit 2bd9307

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
323323
var nextBinding = actionBindings[++i];
324324
while (nextBinding.isPartOfComposite)
325325
{
326-
var name = GetHumanReadableCompositeName(nextBinding);
326+
var name = GetHumanReadableCompositeName(nextBinding, state.selectedControlScheme, state.selectedControlSchemeIndex);
327327

328328
compositeItems.Add(new TreeViewItemData<ActionOrBindingData>(id++,
329329
new ActionOrBindingData(false, name, actionMapIndex, false, GetControlLayout(nextBinding.path), nextBinding.indexOfBinding)));
@@ -341,7 +341,7 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
341341
else
342342
{
343343
bindingItems.Add(new TreeViewItemData<ActionOrBindingData>(id++,
344-
new ActionOrBindingData(false, GetHumanReadableBindingName(serializedInputBinding), actionMapIndex,
344+
new ActionOrBindingData(false, GetHumanReadableBindingName(serializedInputBinding, state.selectedControlSchemeIndex, state.selectedControlScheme), actionMapIndex,
345345
false, GetControlLayout(serializedInputBinding.path), serializedInputBinding.indexOfBinding)));
346346
}
347347
}
@@ -351,18 +351,28 @@ public static List<TreeViewItemData<ActionOrBindingData>> GetActionsAsTreeViewDa
351351
return actionItems;
352352
}
353353

354-
private static string GetHumanReadableBindingName(SerializedInputBinding serializedInputBinding)
354+
private static string GetHumanReadableBindingName(SerializedInputBinding serializedInputBinding, int currentControlSchemeIndex, InputControlScheme? currentControlScheme)
355355
{
356356
var name = InputControlPath.ToHumanReadableString(serializedInputBinding.path);
357357
if (String.IsNullOrEmpty(name))
358358
name = "<No Binding>";
359+
if (!IsBindingPartOfCurrentControlScheme(serializedInputBinding, currentControlScheme, currentControlSchemeIndex))
360+
name += " {GLOBAL}";
359361
return name;
360362
}
361363

362-
internal static string GetHumanReadableCompositeName(SerializedInputBinding binding)
364+
private static bool IsBindingPartOfCurrentControlScheme(SerializedInputBinding serializedInputBinding, InputControlScheme? currentControlScheme, int currentControlSchemeIndex)
365+
{
366+
if (currentControlScheme.HasValue && currentControlSchemeIndex >= 0)
367+
return serializedInputBinding.controlSchemes.Contains(currentControlScheme.Value.name);
368+
369+
return true;
370+
}
371+
372+
internal static string GetHumanReadableCompositeName(SerializedInputBinding binding, InputControlScheme? currentControlScheme, int currentControlSchemeIndex)
363373
{
364374
return $"{ObjectNames.NicifyVariableName(binding.name)}: " +
365-
$"{GetHumanReadableBindingName(binding)}";
375+
$"{GetHumanReadableBindingName(binding, currentControlSchemeIndex, currentControlScheme)}";
366376
}
367377

368378
private static string GetControlLayout(string path)

0 commit comments

Comments
 (0)