Skip to content

Commit 54fd309

Browse files
author
Rene Damm
authored
FIX: Exceptions when opening new project (case 1313185, #1453).
1 parent 5b7ad60 commit 54fd309

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

Packages/com.unity.inputsystem/CHANGELOG.md

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

3333
#### Actions
3434

35+
- Fixed opening a new project (or one that needs a full reimport) leading to several exceptions in the console if the most recently opened project was closed with a `.inputactions` editor open ([case 1313185](https://issuetracker.unity3d.com/issues/exceptions-about-previously-open-action-map-being-thrown-when-opening-new-project)).
3536
- Fixed incorrect indentation of input actions in the inspector ([case 1285546](https://issuetracker.unity3d.com/product/unity/issues/guid/1285546/)).
3637
- Fixed an issue where serialized `InputAction` properties would have display name "Input Action" in the Inspector window instead of their given name. ([case 1367240](https://issuetracker.unity3d.com/product/unity/issues/guid/1367240)).
3738
- Fixed an issue where `InputAction.Enable` would not reuse memory allocated prior and thus lead to memory leaks ([case 1367442](https://issuetracker.unity3d.com/issues/input-system-puts-a-lot-of-pressure-on-the-garbage-collector-when-enabling-and-disabling-inputactionmaps)).

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionAssetManager.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public string path
2929
get
3030
{
3131
Debug.Assert(!string.IsNullOrEmpty(m_AssetGUID), "Asset GUID is empty");
32-
var assetPath = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
33-
if (string.IsNullOrEmpty(assetPath))
34-
throw new InvalidOperationException("Could not determine asset path for " + m_AssetGUID);
35-
return assetPath;
32+
return AssetDatabase.GUIDToAssetPath(m_AssetGUID);
3633
}
3734
}
3835

@@ -133,7 +130,17 @@ public void Cleanup()
133130

134131
public void LoadImportedObjectFromGuid()
135132
{
136-
m_ImportedAssetObject = AssetDatabase.LoadAssetAtPath<InputActionAsset>(path);
133+
// https://fogbugz.unity3d.com/f/cases/1313185/
134+
// InputActionEditorWindow being an EditorWindow, it will be saved as part of the editor's
135+
// window layout. When a project is opened that has no Library/ folder, the layout from the
136+
// most recently opened project is used. Which means that when opening an .inputactions
137+
// asset in project A, then closing it, and then opening project B, restoring the window layout
138+
// also tries to restore the InputActionEditorWindow having that very same asset open -- which
139+
// will lead nowhere except there happens to be an InputActionAsset with the very same GUID in
140+
// the project.
141+
var assetPath = path;
142+
if (!string.IsNullOrEmpty(assetPath))
143+
m_ImportedAssetObject = AssetDatabase.LoadAssetAtPath<InputActionAsset>(assetPath);
137144
}
138145

139146
public void ApplyChanges()

0 commit comments

Comments
 (0)