Skip to content

Commit 0e65d84

Browse files
committed
fix: Fixed generic types databases not being initialized sometimes
the fact that we don't check for changes to generic types when entering play mode doesn't mean we should initialized databases because they need to be initialized on every domain reload. Fixed this
1 parent f301bda commit 0e65d84

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Editor/GenericTypesAnalyzer/GenericTypesAnalyzer.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ private static void AnalyzeGenericTypes()
2525
// If PlayOptions is disabled and the domain reload happens on entering Play Mode, no changes to scripts
2626
// can be detected but NullReferenceException is thrown from UnityEditor internals. Since it is useless
2727
// to check changes to scripts in this situation, we can safely ignore this domain reload.
28-
if (EditorApplication.isPlayingOrWillChangePlaymode)
29-
return;
28+
if ( ! EditorApplication.isPlayingOrWillChangePlaymode)
29+
UpdateGeneratedAssemblies();
3030

31+
DictInitializer<MonoBehaviour>.Initialize();
32+
DictInitializer<GenericScriptableObject>.Initialize();
33+
}
34+
35+
private static void UpdateGeneratedAssemblies()
36+
{
3137
#if GENERIC_UNITY_OBJECTS_DEBUG
3238
using var timer = Timer.CheckInMilliseconds("AnalyzeGenericTypes");
3339
#endif
@@ -54,9 +60,6 @@ private static void AnalyzeGenericTypes()
5460

5561
if (behavioursNeedDatabaseRefresh || scriptableObjectsNeedDatabaseRefresh)
5662
AssetDatabase.Refresh();
57-
58-
DictInitializer<MonoBehaviour>.Initialize();
59-
DictInitializer<GenericScriptableObject>.Initialize();
6063
}
6164
}
6265
}

0 commit comments

Comments
 (0)