Skip to content

Commit ff61a76

Browse files
committed
WIP
1 parent c262725 commit ff61a76

File tree

7 files changed

+41
-21
lines changed

7 files changed

+41
-21
lines changed

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,7 @@ private void OnCompositeParametersModified()
316316
var nameAndParameters = NameAndParameters.Parse(path);
317317
nameAndParameters.parameters = m_CompositeParameters.GetParameters();
318318

319-
m_PathProperty.stringValue = nameAndParameters.ToString();
320-
m_PathProperty.serializedObject.ApplyModifiedProperties();
321-
322-
OnPathChanged();
319+
OnPathChanged(nameAndParameters.ToString());
323320
}
324321

325322
private void OnBindingGroupsChanged()
@@ -330,8 +327,9 @@ private void OnBindingGroupsChanged()
330327
onChange?.Invoke(k_GroupsChanged);
331328
}
332329

333-
private void OnPathChanged()
330+
private void OnPathChanged(string path)
334331
{
332+
m_PathProperty.stringValue = path;
335333
m_BindingProperty.serializedObject.ApplyModifiedProperties();
336334
onChange?.Invoke(k_PathChanged);
337335
}

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public sealed class InputControlPathEditor : IDisposable
2626
/// <param name="onModified">Delegate that is called when the path has been modified.</param>
2727
/// <param name="label">Optional label to display instead of display name of <paramref name="pathProperty"/>.</param>
2828
/// <exception cref="ArgumentNullException"><paramref name="pathProperty"/> is <c>null</c>.</exception>
29-
public InputControlPathEditor(SerializedProperty pathProperty, InputControlPickerState pickerState, Action onModified, GUIContent label = null)
29+
public InputControlPathEditor(SerializedProperty pathProperty, InputControlPickerState pickerState, Action<string> onModified, GUIContent label = null)
3030
{
3131
if (pathProperty == null)
3232
throw new ArgumentNullException(nameof(pathProperty));
@@ -89,7 +89,7 @@ public void OnGUI()
8989
EditorGUILayout.EndHorizontal();
9090
}
9191

92-
public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action modifiedCallback = null)
92+
public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty property = null, Action<string> modifiedCallback = null)
9393
{
9494
var pathLabel = label ?? m_PathLabel;
9595
var serializedProperty = property ?? pathProperty;
@@ -141,7 +141,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
141141
{
142142
serializedProperty.stringValue = path;
143143
serializedProperty.serializedObject.ApplyModifiedProperties();
144-
(modifiedCallback ?? onModified).Invoke();
144+
(modifiedCallback ?? onModified).Invoke(path);
145145
}
146146
}
147147
else
@@ -151,7 +151,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
151151
{
152152
SetExpectedControlLayoutFromAttribute(serializedProperty);
153153
////TODO: for bindings that are part of composites, use the layout information from the [InputControl] attribute on the field
154-
ShowDropdown(bindingTextRect, serializedProperty, modifiedCallback ?? onModified);
154+
ShowDropdown(bindingTextRect, modifiedCallback ?? onModified);
155155
}
156156
}
157157

@@ -160,7 +160,7 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
160160
EditorStyles.miniButton);
161161
}
162162

163-
private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback)
163+
private void ShowDropdown(Rect rect, Action<string> modifiedCallback)
164164
{
165165
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
166166
InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(true, false);
@@ -171,19 +171,16 @@ private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Acti
171171
m_PickerState,
172172
path =>
173173
{
174-
serializedProperty.stringValue = path;
175174
m_PickerState.manualPathEditMode = false;
176-
modifiedCallback();
175+
modifiedCallback(path);
177176
});
178177
}
179178

180179
m_PickerDropdown.SetPickedCallback(path =>
181180
{
182181
//At this point, the serialized property can sometines be referencing the old input actions asset
183-
Debug.Log(serializedProperty.serializedObject.targetObject.GetInstanceID());
184-
serializedProperty.stringValue = path;
185182
m_PickerState.manualPathEditMode = false;
186-
modifiedCallback();
183+
modifiedCallback(path);
187184
});
188185

189186
m_PickerDropdown.SetControlPathsToMatch(m_ControlPathsToMatch);
@@ -204,7 +201,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property)
204201
}
205202

206203
public SerializedProperty pathProperty { get; }
207-
public Action onModified { get; }
204+
public Action<string> onModified { get; }
208205

209206
private GUIContent m_PathLabel;
210207
private string m_ExpectedControlLayout;
@@ -215,6 +212,7 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property)
215212
private InputControlPickerDropdown m_PickerDropdown;
216213
private readonly InputControlPickerState m_PickerState;
217214
private InputActionRebindingExtensions.RebindingOperation m_RebindingOperation;
215+
218216
}
219217
}
220218
#endif // UNITY_EDITOR

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ protected override void ItemSelected(AdvancedDropdownItem item)
127127
InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(false, true);
128128
#endif
129129
var path = ((InputControlDropdownItem)item).controlPathWithDevice;
130+
Debug.Log("Picked: " + path);
130131
m_OnPickCallback(path);
131132
}
132133

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputControlPathDrawer.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,20 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3939
if (m_Editor == null)
4040
{
4141
m_Editor = new InputControlPathEditor(property, m_PickerState,
42-
() => property.serializedObject.ApplyModifiedProperties(),
42+
(path) =>
43+
{
44+
property.stringValue = path;
45+
property.serializedObject.ApplyModifiedProperties();
46+
},
4347
label: label);
4448
}
45-
49+
4650
EditorGUI.BeginProperty(position, label, property);
47-
m_Editor.OnGUI(position, label, property, () => property.serializedObject.ApplyModifiedProperties());
51+
m_Editor.OnGUI(position, label, property, (path) =>
52+
{
53+
property.stringValue = path;
54+
property.serializedObject.ApplyModifiedProperties();
55+
});
4856
EditorGUI.EndProperty();
4957
}
5058
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ internal class ActionsTreeView : ViewBase<ActionsTreeView.ViewState>
3232
public ActionsTreeView(VisualElement root, StateContainer stateContainer)
3333
: base(root, stateContainer)
3434
{
35+
Debug.Log("Rebuilding TreeView");
3536
m_ActionMapsListView = root.Q<ListView>("action-maps-list-view");
3637
m_AddActionButton = root.Q<Button>("add-new-action-button");
3738
m_PropertiesScrollview = root.Q<ScrollView>("properties-scrollview");
@@ -106,6 +107,12 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
106107
item.FocusOnRenameTextField();
107108
};
108109

110+
m_ActionsTreeView.selectionChanged += objects =>
111+
{
112+
var data = (ActionOrBindingData)objects.FirstOrDefault();
113+
Debug.Log($"Selection Changed {data.actionIndex} . {data.bindingIndex}");
114+
};
115+
109116
m_ActionsTreeView.unbindItem = (element, i) =>
110117
{
111118
var item = m_ActionsTreeView.GetItemDataForIndex<ActionOrBindingData>(i);

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/BindingPropertiesView.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public override void RedrawUI(ViewState viewState)
5959
else
6060
{
6161
var controlPathEditor = new InputControlPathEditor(viewState.selectedBindingPath, new InputControlPickerState(),
62-
() => { Dispatch(Commands.ApplyModifiedProperties()); });
62+
(path) =>
63+
{
64+
viewState.selectedBindingPath.stringValue = path;
65+
Dispatch(Commands.ApplyModifiedProperties());
66+
});
6367
controlPathEditor.SetControlPathsToMatch(viewState.currentControlScheme.deviceRequirements.Select(x => x.controlPath));
6468

6569
var inputAction = viewState.selectedInputAction;

Diff for: Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositePartBindingPropertiesView.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public override void RedrawUI(ViewState viewState)
3636
return;
3737
// TODO: Persist control picker state
3838
var controlPathEditor = new InputControlPathEditor(viewState.selectedBindingPath, new InputControlPickerState(),
39-
() => { Dispatch(Commands.ApplyModifiedProperties()); });
39+
(path) =>
40+
{
41+
viewState.selectedBindingPath.stringValue = path;
42+
Dispatch(Commands.ApplyModifiedProperties());
43+
});
4044

4145
controlPathEditor.SetControlPathsToMatch(viewState.currentControlScheme.deviceRequirements.Select(x => x.controlPath));
4246
controlPathEditor.SetExpectedControlLayout(viewState.expectedControlLayoutName);

0 commit comments

Comments
 (0)