Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: tree state in treeview should be preserved when saving (ISXB-966) #1967

Merged
merged 13 commits into from
Aug 19, 2024
Merged
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ however, it has to be formatted properly to pass verification tests.

### Fixed
- Fixed default scroll speed in uGUI being slower than before. [ISXB-766](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-766)
- Fixed selection state preserving after a save operation. [ISXB-966](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-966)
- 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).
- 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).
- Fixed ArgumentNullException thrown when accessing Action's bindings after changing Composite part. [ISXB-494](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-494).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ private void BuildUI()
// If the editor is associated with an asset we show input action editor
if (hasAsset)
{
m_StateContainer = new StateContainer(m_State);
m_StateContainer = new StateContainer(m_State, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)));
m_StateContainer.StateChanged += OnStateChanged;
m_View = new InputActionsEditorView(m_RootVisualElement, m_StateContainer, true, null);
m_StateContainer.Initialize(m_RootVisualElement.Q("action-editor"));
}
}

private InputActionAsset GetAsset()
{
return m_State.serializedObject?.targetObject as InputActionAsset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void BuildUI()
if (m_State.m_Analytics == null)
m_State.m_Analytics = m_Analytics;

m_StateContainer = new StateContainer(m_State);
m_StateContainer = new StateContainer(m_State, m_AssetGUID);
m_StateContainer.StateChanged += OnStateChanged;

rootVisualElement.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ internal class StateContainer

private VisualElement m_RootVisualElement;
private InputActionsEditorState m_State;
public readonly string assetGUID;

public StateContainer(InputActionsEditorState initialState)
public StateContainer(InputActionsEditorState initialState, string assetGUID)
{
m_State = initialState;
this.assetGUID = assetGUID;
}

public void Dispatch(Command command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ActionsTreeView(VisualElement root, StateContainer stateContainer)
m_PropertiesScrollview = root.Q<ScrollView>("properties-scrollview");
m_ActionsTreeView = root.Q<TreeView>("actions-tree-view");
//assign unique viewDataKey to store treeView states like expanded/collapsed items - make it unique to avoid conflicts with other TreeViews
m_ActionsTreeView.viewDataKey = "InputActionTreeView " + stateContainer.GetState().serializedObject.targetObject.GetInstanceID();
m_ActionsTreeView.viewDataKey = $"InputActionTreeView_{stateContainer.assetGUID}";
m_GuidToTreeViewId = new Dictionary<Guid, int>();
m_ActionsTreeView.selectionType = UIElements.SelectionType.Single;
m_ActionsTreeView.makeItem = () => new InputActionsTreeViewItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public InputActionsEditorView(VisualElement root, StateContainer stateContainer,
InputActionsEditorConstants.PackagePath +
InputActionsEditorConstants.ResourcesPath +
InputActionsEditorConstants.MainEditorViewNameUxml);

mainEditorAsset.CloneTree(root);
var actionsTreeView = new ActionsTreeView(root, stateContainer);
CreateChildView(new ActionMapsView(root, stateContainer));
Expand Down