Skip to content

Commit fbd60e3

Browse files
authored
Merge pull request #40 from brunomikoski/bugfix/fix-null-type-error
fix: if the type becomes null
2 parents 86c00d9 + da6dc26 commit fbd60e3

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

Scripts/Editor/CreateNewCollectableType.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ private void OnDisable()
4949

5050
private void OnGUI()
5151
{
52+
if (targetType == null)
53+
{
54+
onCreationCallback?.Invoke(false);
55+
Close();
56+
return;
57+
}
58+
5259
using (new EditorGUILayout.VerticalScope("Box"))
5360
{
5461
using (new EditorGUILayout.VerticalScope("Box"))

Scripts/Editor/ScriptableObjectCollectionCustomEditor.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,19 @@ public static void AfterStaticAssemblyReload()
259259

260260
isWaitingForNewTypeBeCreated = false;
261261

262-
if (string.IsNullOrEmpty(CreateNewCollectableType.LastGeneratedCollectionScriptPath))
263-
return;
264-
265-
string assemblyName = CompilationPipeline.GetAssemblyNameFromScriptPath(CreateNewCollectableType
266-
.LastGeneratedCollectionScriptPath);
267-
268-
Type targetType = Type.GetType($"{CreateNewCollectableType.LastCollectionFullName}, {assemblyName}");
262+
string lastGeneratedCollectionScriptPath = CreateNewCollectableType.LastGeneratedCollectionScriptPath;
263+
string lastCollectionFullName = CreateNewCollectableType.LastCollectionFullName;
269264

265+
if (string.IsNullOrEmpty(lastGeneratedCollectionScriptPath))
266+
return;
267+
270268
CreateNewCollectableType.LastCollectionFullName = string.Empty;
271269
CreateNewCollectableType.LastGeneratedCollectionScriptPath = string.Empty;
272270

271+
string assemblyName = CompilationPipeline.GetAssemblyNameFromScriptPath(lastGeneratedCollectionScriptPath);
272+
273+
Type targetType = Type.GetType($"{lastCollectionFullName}, {assemblyName}");
274+
273275
if (CollectionsRegistry.Instance.TryGetCollectionForType(targetType,
274276
out ScriptableObjectCollection collection))
275277
{

0 commit comments

Comments
 (0)