jsonproperty experiment
This commit is contained in:
parent
427cc3f175
commit
67431f2ad4
@ -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}");
|
||||
|
||||
@ -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<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;
|
||||
}
|
||||
|
||||
ClonePrefab();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user