Make InstantiateCluster more robust

This commit is contained in:
Pascal Serrarens 2026-05-27 13:03:32 +02:00
parent 5e73335997
commit 6bc6f19637

View File

@ -37,13 +37,18 @@ namespace NanoBrain.Unity {
} }
private void InstantiateCluster(SerializedProperty property, ClusterView clusterView) { private void InstantiateCluster(SerializedProperty property, ClusterView clusterView) {
if (property == null || property.serializedObject == null || clusterView.initialized) if (property == null || clusterView.initialized)
return; return;
SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); SerializedObject serializedObject = property.serializedObject;
UnityEngine.Object targetObject = property.serializedObject.targetObject; if (serializedObject == null)
return;
UnityEngine.Object targetObject = serializedObject.targetObject;
if (targetObject == null) if (targetObject == null)
return; return;
SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab));
Debug.Log($"Instantiate new Cluster for {targetObject.name}"); Debug.Log($"Instantiate new Cluster for {targetObject.name}");