jsonproperty experiment

This commit is contained in:
Pascal Serrarens 2026-08-10 14:14:41 +02:00
parent 427cc3f175
commit 67431f2ad4
4 changed files with 12 additions and 2 deletions

View File

@ -75,12 +75,15 @@ namespace NanoBrain.Unity {
int indent = EditorGUI.indentLevel; int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0; EditorGUI.indentLevel = 0;
//SerializedProperty jsonProp = property.FindPropertyRelative(nameof(Cluster.jsonAsset));
SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab));
// Draw the object field on the top line // Draw the object field on the top line
Rect fieldRect = new(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); Rect fieldRect = new(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.BeginChangeCheck(); 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 a new prefab has been selected
if (EditorGUI.EndChangeCheck()) { if (EditorGUI.EndChangeCheck()) {
Debug.Log($"Cluster change, Event is {Event.current.type}"); Debug.Log($"Cluster change, Event is {Event.current.type}");

View File

@ -26,6 +26,7 @@ namespace NanoBrain {
/// Cluster should always be created from prefabs /// Cluster should always be created from prefabs
public ClusterPrefab prefab; public ClusterPrefab prefab;
public ClusterJson json; public ClusterJson json;
public TextAsset jsonAsset;
//[HideInInspector] //[HideInInspector]
@ -129,8 +130,14 @@ namespace NanoBrain {
this.prefab = prefab; this.prefab = prefab;
this.version = prefab.version; this.version = prefab.version;
this.name = prefab.name; this.name = prefab.name;
if (parent != null) if (parent != null) {
TextAsset jsonFile = Resources.Load<TextAsset>(parent.name);
string json = jsonFile.text;
ClusterData clusterData = JsonUtility.FromJson<ClusterData>(json);
//ClusterData clusterData = Cluster.Import(jsonPath);
parent.cluster = new(clusterData);
this.parent = parent.cluster; this.parent = parent.cluster;
}
ClonePrefab(); ClonePrefab();
} }