Skip to content

Commit 730bb23

Browse files
authored
FIX: tree state in treeview should be preserved when saving (ISXB-966) (#1967)
* fixed selection behaviour in action tree. * viewDataKey needs to be consistent across domain reloads
1 parent e1f069b commit 730bb23

5 files changed

Lines changed: 7 additions & 9 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ however, it has to be formatted properly to pass verification tests.
2727

2828
### Fixed
2929
- Fixed default scroll speed in uGUI being slower than before. [ISXB-766](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-766)
30+
- Fixed selection state preserving after a save operation. [ISXB-966](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-966)
3031
- Fixed an issue when multiple interactions drive an action and perform during the cancelation of the current active interaction [ISXB-310](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-310).
3132
- Fixed an issue when generating C# class of Input Actions that contain an action map named `Debug` [ISXB-851](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-851).
3233
- Fixed ArgumentNullException thrown when accessing Action's bindings after changing Composite part. [ISXB-494](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-494).

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private void BuildUI()
259259
// If the editor is associated with an asset we show input action editor
260260
if (hasAsset)
261261
{
262-
m_StateContainer = new StateContainer(m_State);
262+
m_StateContainer = new StateContainer(m_State, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)));
263263
m_StateContainer.StateChanged += OnStateChanged;
264264
m_View = new InputActionsEditorView(m_RootVisualElement, m_StateContainer, true, null);
265265
m_StateContainer.Initialize(m_RootVisualElement.Q("action-editor"));

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private void BuildUI()
226226
if (m_State.m_Analytics == null)
227227
m_State.m_Analytics = m_Analytics;
228228

229-
m_StateContainer = new StateContainer(m_State);
229+
m_StateContainer = new StateContainer(m_State, m_AssetGUID);
230230
m_StateContainer.StateChanged += OnStateChanged;
231231

232232
rootVisualElement.Clear();

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ internal class StateContainer
1313

1414
private VisualElement m_RootVisualElement;
1515
private InputActionsEditorState m_State;
16+
public readonly string assetGUID;
1617

17-
public StateContainer(InputActionsEditorState initialState)
18+
public StateContainer(InputActionsEditorState initialState, string assetGUID)
1819
{
1920
m_State = initialState;
21+
this.assetGUID = assetGUID;
2022
}
2123

2224
public void Dispatch(Command command)

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
3737
m_PropertiesScrollview = root.Q<ScrollView>("properties-scrollview");
3838
m_ActionsTreeView = root.Q<TreeView>("actions-tree-view");
3939
//assign unique viewDataKey to store treeView states like expanded/collapsed items - make it unique to avoid conflicts with other TreeViews
40-
m_ActionsTreeView.viewDataKey = "InputActionTreeView " + stateContainer.GetState().serializedObject.targetObject.GetInstanceID();
40+
m_ActionsTreeView.viewDataKey = $"InputActionTreeView_{stateContainer.assetGUID}";
4141
m_GuidToTreeViewId = new Dictionary<Guid, int>();
4242
m_ActionsTreeView.selectionType = UIElements.SelectionType.Single;
4343
m_ActionsTreeView.makeItem = () => new InputActionsTreeViewItem();
@@ -135,11 +135,6 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
135135
var item = m_ActionsTreeView.GetItemDataForIndex<ActionOrBindingData>(m_ActionsTreeView.selectedIndex);
136136
Dispatch(item.isAction ? Commands.SelectAction(item.name) : Commands.SelectBinding(item.bindingIndex));
137137
}
138-
else
139-
{
140-
Dispatch(Commands.SelectAction(null));
141-
Dispatch(Commands.SelectBinding(-1));
142-
}
143138
};
144139

145140
m_ActionsTreeView.RegisterCallback<ExecuteCommandEvent>(OnExecuteCommand);

0 commit comments

Comments
 (0)