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}");