diff --git a/Editor/Cluster_Drawer.cs b/Editor/Cluster_Drawer.cs index 68c7485..f85d735 100644 --- a/Editor/Cluster_Drawer.cs +++ b/Editor/Cluster_Drawer.cs @@ -75,12 +75,15 @@ namespace NanoBrain.Unity { int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; + //SerializedProperty jsonProp = property.FindPropertyRelative(nameof(Cluster.jsonAsset)); + SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); // Draw the object field on the top line Rect fieldRect = new(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); EditorGUI.BeginChangeCheck(); - EditorGUI.PropertyField(fieldRect, prefabProp, label); + //EditorGUI.PropertyField(fieldRect, jsonProp, label); + //EditorGUI.PropertyField(fieldRect, prefabProp, label); // If a new prefab has been selected if (EditorGUI.EndChangeCheck()) { Debug.Log($"Cluster change, Event is {Event.current.type}"); diff --git a/Runtime/Scripts/Core/Cluster.cs b/Runtime/Scripts/Core/Cluster.cs index c664a1e..96bddd9 100644 --- a/Runtime/Scripts/Core/Cluster.cs +++ b/Runtime/Scripts/Core/Cluster.cs @@ -26,6 +26,7 @@ namespace NanoBrain { /// Cluster should always be created from prefabs public ClusterPrefab prefab; public ClusterJson json; + public TextAsset jsonAsset; //[HideInInspector] @@ -129,8 +130,14 @@ namespace NanoBrain { this.prefab = prefab; this.version = prefab.version; this.name = prefab.name; - if (parent != null) + if (parent != null) { + TextAsset jsonFile = Resources.Load(parent.name); + string json = jsonFile.text; + ClusterData clusterData = JsonUtility.FromJson(json); + //ClusterData clusterData = Cluster.Import(jsonPath); + parent.cluster = new(clusterData); this.parent = parent.cluster; + } ClonePrefab(); } diff --git a/Runtime/Scripts/ClusterJson.cs b/Runtime/Scripts/ScriptableObjects/ClusterJson.cs similarity index 100% rename from Runtime/Scripts/ClusterJson.cs rename to Runtime/Scripts/ScriptableObjects/ClusterJson.cs diff --git a/Runtime/Scripts/ClusterJson.cs.meta b/Runtime/Scripts/ScriptableObjects/ClusterJson.cs.meta similarity index 100% rename from Runtime/Scripts/ClusterJson.cs.meta rename to Runtime/Scripts/ScriptableObjects/ClusterJson.cs.meta