From 6bc6f196376ad2812bdd0e16a8ee9d80eddab65d Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 27 May 2026 13:03:32 +0200 Subject: [PATCH] Make InstantiateCluster more robust --- Editor/Cluster_Drawer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Editor/Cluster_Drawer.cs b/Editor/Cluster_Drawer.cs index 2a15872..d33bbf1 100644 --- a/Editor/Cluster_Drawer.cs +++ b/Editor/Cluster_Drawer.cs @@ -37,13 +37,18 @@ namespace NanoBrain.Unity { } private void InstantiateCluster(SerializedProperty property, ClusterView clusterView) { - if (property == null || property.serializedObject == null || clusterView.initialized) + if (property == null || clusterView.initialized) return; - SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); - UnityEngine.Object targetObject = property.serializedObject.targetObject; + SerializedObject serializedObject = property.serializedObject; + if (serializedObject == null) + return; + + UnityEngine.Object targetObject = serializedObject.targetObject; if (targetObject == null) return; + + SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); Debug.Log($"Instantiate new Cluster for {targetObject.name}");