From a2f108322a904fc47c9bb03e6a760504144bb193 Mon Sep 17 00:00:00 2001 From: Rita Merkl Date: Thu, 3 Aug 2023 13:55:36 +0200 Subject: [PATCH] implemented indicating bindings not included into the current control scheme --- .../UITKAssetEditor/Views/ActionsTreeView.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs index e7477e03b6..23401dcb54 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionsTreeView.cs @@ -315,7 +315,7 @@ public static List> GetActionsAsTreeViewDa var nextBinding = actionBindings[++i]; while (nextBinding.isPartOfComposite) { - var name = GetHumanReadableCompositeName(nextBinding); + var name = GetHumanReadableCompositeName(nextBinding, state.selectedControlScheme, state.selectedControlSchemeIndex); compositeItems.Add(new TreeViewItemData(id++, new ActionOrBindingData(false, name, actionMapIndex, false, GetControlLayout(nextBinding.path), nextBinding.indexOfBinding))); @@ -333,7 +333,7 @@ public static List> GetActionsAsTreeViewDa else { bindingItems.Add(new TreeViewItemData(id++, - new ActionOrBindingData(false, GetHumanReadableBindingName(serializedInputBinding), actionMapIndex, + new ActionOrBindingData(false, GetHumanReadableBindingName(serializedInputBinding, state.selectedControlSchemeIndex, state.selectedControlScheme), actionMapIndex, false, GetControlLayout(serializedInputBinding.path), serializedInputBinding.indexOfBinding))); } } @@ -343,18 +343,28 @@ public static List> GetActionsAsTreeViewDa return actionItems; } - private static string GetHumanReadableBindingName(SerializedInputBinding serializedInputBinding) + private static string GetHumanReadableBindingName(SerializedInputBinding serializedInputBinding, int currentControlSchemeIndex, InputControlScheme? currentControlScheme) { var name = InputControlPath.ToHumanReadableString(serializedInputBinding.path); if (String.IsNullOrEmpty(name)) name = ""; + if (!IsBindingPartOfCurrentControlScheme(serializedInputBinding, currentControlScheme, currentControlSchemeIndex)) + name += " {GLOBAL}"; return name; } - internal static string GetHumanReadableCompositeName(SerializedInputBinding binding) + private static bool IsBindingPartOfCurrentControlScheme(SerializedInputBinding serializedInputBinding, InputControlScheme? currentControlScheme, int currentControlSchemeIndex) + { + if (currentControlScheme.HasValue && currentControlSchemeIndex >= 0) + return serializedInputBinding.controlSchemes.Contains(currentControlScheme.Value.name); + + return true; + } + + internal static string GetHumanReadableCompositeName(SerializedInputBinding binding, InputControlScheme? currentControlScheme, int currentControlSchemeIndex) { return $"{ObjectNames.NicifyVariableName(binding.name)}: " + - $"{GetHumanReadableBindingName(binding)}"; + $"{GetHumanReadableBindingName(binding, currentControlSchemeIndex, currentControlScheme)}"; } private static string GetControlLayout(string path)