Skip to content

Commit ba9677b

Browse files
authored
CHANGE: Performance improvement - removed project-wide asset migration code (#2025)
This was only required to fix projects created with 1.8.0-pre-release versions. As it adds a performance cost on each domain reload the decision was made to removing this performance improvement.
1 parent 24012a0 commit ba9677b

File tree

2 files changed

+3
-74
lines changed

2 files changed

+3
-74
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ however, it has to be formatted properly to pass verification tests.
2424
### Fixed
2525
- Removed a redundant warning when using fallback code to parse a HID descriptor. (UUM-71260)
2626

27+
### Changed
28+
- Removed the InputManager to InputSystem project-wide asset migration code for performance improvement (ISX-2086)
29+
2730
## [1.11.1] - 2024-09-26
2831

2932
### Fixed

Packages/com.unity.inputsystem/InputSystem/Editor/ProjectWideActions/ProjectWideActionsAsset.cs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,14 @@ internal static class ProjectWideActionsAsset
1717

1818
internal static class ProjectSettingsProjectWideActionsAssetConverter
1919
{
20-
private const string kAssetPathInputManager = "ProjectSettings/InputManager.asset";
21-
private const string kAssetNameProjectWideInputActions = "ProjectWideInputActions";
22-
2320
class ProjectSettingsPostprocessor : AssetPostprocessor
2421
{
25-
private static bool migratedInputActionAssets = false;
26-
2722
#if UNITY_2021_2_OR_NEWER
2823
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
2924
#else
3025
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
3126
#endif
3227
{
33-
if (!migratedInputActionAssets)
34-
{
35-
MoveInputManagerAssetActionsToProjectWideInputActionAsset();
36-
migratedInputActionAssets = true;
37-
}
38-
3928
if (!Application.isPlaying)
4029
{
4130
// If the Library folder is deleted, InputSystem will fail to retrieve the assigned Project-wide Asset because this look-up occurs
@@ -46,69 +35,6 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del
4635
}
4736
}
4837
}
49-
50-
private static void MoveInputManagerAssetActionsToProjectWideInputActionAsset()
51-
{
52-
var objects = AssetDatabase.LoadAllAssetsAtPath(EditorHelpers.GetPhysicalPath(kAssetPathInputManager));
53-
if (objects == null)
54-
return;
55-
56-
var inputActionsAsset = objects.FirstOrDefault(o => o != null && o.name == kAssetNameProjectWideInputActions) as InputActionAsset;
57-
if (inputActionsAsset != default)
58-
{
59-
// Found some actions in the InputManager.asset file
60-
//
61-
string path = ProjectWideActionsAsset.kDefaultAssetPath;
62-
63-
if (File.Exists(EditorHelpers.GetPhysicalPath(path)))
64-
{
65-
// We already have a path containing inputactions, find a new unique filename
66-
//
67-
// eg Assets/InputSystem_Actions.inputactions ->
68-
// Assets/InputSystem_Actions (1).inputactions ->
69-
// Assets/InputSystem_Actions (2).inputactions ...
70-
//
71-
string[] files = Directory.GetFiles("Assets", "*.inputactions");
72-
List<string> names = new List<string>();
73-
for (int i = 0; i < files.Length; i++)
74-
{
75-
names.Add(System.IO.Path.GetFileNameWithoutExtension(files[i]));
76-
}
77-
string unique = ObjectNames.GetUniqueName(names.ToArray(), kDefaultAssetName);
78-
path = "Assets/" + unique + ".inputactions";
79-
}
80-
81-
var json = inputActionsAsset.ToJson();
82-
InputActionAssetManager.SaveAsset(EditorHelpers.GetPhysicalPath(path), json);
83-
84-
Debug.Log($"Migrated Project-wide Input Actions from '{kAssetPathInputManager}' to '{path}' asset");
85-
86-
// Update current project-wide settings if needed (don't replace if already set to something else)
87-
//
88-
if (InputSystem.actions == null || InputSystem.actions.name == kAssetNameProjectWideInputActions)
89-
{
90-
InputSystem.actions = (InputActionAsset)AssetDatabase.LoadAssetAtPath(path, typeof(InputActionAsset));
91-
Debug.Log($"Loaded Project-wide Input Actions from '{path}' asset");
92-
}
93-
}
94-
95-
// Handle deleting all InputActionAssets as older 1.8.0 pre release could create more than one project wide input asset in the file
96-
foreach (var obj in objects)
97-
{
98-
if (obj is InputActionReference)
99-
{
100-
var actionReference = obj as InputActionReference;
101-
AssetDatabase.RemoveObjectFromAsset(obj);
102-
Object.DestroyImmediate(actionReference);
103-
}
104-
else if (obj is InputActionAsset)
105-
{
106-
AssetDatabase.RemoveObjectFromAsset(obj);
107-
}
108-
}
109-
110-
AssetDatabase.SaveAssets();
111-
}
11238
}
11339

11440
// Returns the default asset path for where to create project-wide actions asset.

0 commit comments

Comments
 (0)