Changes to Project-wide Actions within the Project Settings are saved (to the Asset) automatically when the window looses focus, however I found a few scenarios were this doesn't occur and changes to the ActionMap aren't properly saved causing an exception when entering PlayMode.
There's a strange disconnect between the problem this PR fixes and the issue detailed in the ticket. As I understand it, restoring the UI ActionMap updates the Actions state in memory but it links the "old" Asset within ReadFromJson.ToAsset() (from InputActionAsset.cs) to the ActionMap. Typically, the changes are saved and serialized to the Asset at which point the ToAsset() operation is performed again and the correct Asset is linked to the ActionMap, but if we skip saving the Asset (as is the case with this bug) the InputActionMap.m_Asset never gets updated and remains null.
Ensuring the Asset is always properly saved in ProjectSettings fixes this issue and may address other issues as well.
Changes made
Adds calls to SaveAssetOnFocusLost() within InputActionsEditorSettingsProvider to cover additional scenario in which the asset needs to be saved (FocusLost isn't fired in these cases):
OnDeactivate() save after changing the "active" settings within ProjectSettings window or the window is closed
ModeChanged() save before enter PlayMode
Notes
I updated the ticket with repro steps to cover the previously mentioned scenarios, and so far haven't been able to discover any other corner cases.
Checklist
Before review:
[x] Changelog entry added.
Explains the change in Changed, Fixed, Added sections.
For API change contains an example snippet and/or migration example.
FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
FogBugz is marked as "Resolved" with next release version correctly set.
Description
Changes to Project-wide Actions within the Project Settings are saved (to the Asset) automatically when the window looses focus, however I found a few scenarios were this doesn't occur and changes to the ActionMap aren't properly saved causing an exception when entering PlayMode.
There's a strange disconnect between the problem this PR fixes and the issue detailed in the ticket. As I understand it, restoring the UI ActionMap updates the Actions state in memory but it links the "old" Asset within
ReadFromJson.ToAsset()
(from InputActionAsset.cs) to the ActionMap. Typically, the changes are saved and serialized to the Asset at which point theToAsset()
operation is performed again and the correct Asset is linked to the ActionMap, but if we skip saving the Asset (as is the case with this bug) theInputActionMap.m_Asset
never gets updated and remains null.Ensuring the Asset is always properly saved in ProjectSettings fixes this issue and may address other issues as well.
Changes made
Adds calls to
SaveAssetOnFocusLost()
withinInputActionsEditorSettingsProvider
to cover additional scenario in which the asset needs to be saved (FocusLost isn't fired in these cases):OnDeactivate()
save after changing the "active" settings within ProjectSettings window or the window is closedModeChanged()
save before enter PlayModeNotes
I updated the ticket with repro steps to cover the previously mentioned scenarios, and so far haven't been able to discover any other corner cases.
Checklist
Before review:
Changed
,Fixed
,Added
sections.([case %number%](https://issuetracker.unity3d.com/issues/...))
.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.