mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Fixed open empty NodeGraph
This commit is contained in:
parent
9ef6069ea7
commit
d237e1529b
@ -72,16 +72,24 @@ public class NodeGraph {
|
||||
|
||||
public static NodeGraph Deserialize(string json) {
|
||||
NodeGraph nodeGraph = JsonUtility.FromJson<NodeGraph>(json);
|
||||
for (int i = 0; i < nodeGraph.s_nodes.Length; i++) {
|
||||
NodeTyper tempNode = new NodeTyper();
|
||||
JsonUtility.FromJsonOverwrite(nodeGraph.s_nodes[i],tempNode);
|
||||
//Node node = nodeGraph.AddNode(tempNode.nodeType);
|
||||
Type type = Type.GetType(tempNode.nodeType);
|
||||
Node node = JsonUtility.FromJson(nodeGraph.s_nodes[i], type) as Node;
|
||||
nodeGraph.AddNode(node);
|
||||
|
||||
//If we are trying to open a newly created nodegraph, it will be empty
|
||||
if (nodeGraph == null) nodeGraph = new NodeGraph();
|
||||
if (nodeGraph.s_nodes != null) {
|
||||
|
||||
for (int i = 0; i < nodeGraph.s_nodes.Length; i++) {
|
||||
NodeTyper tempNode = new NodeTyper();
|
||||
JsonUtility.FromJsonOverwrite(nodeGraph.s_nodes[i], tempNode);
|
||||
//Node node = nodeGraph.AddNode(tempNode.nodeType);
|
||||
Type type = Type.GetType(tempNode.nodeType);
|
||||
Node node = JsonUtility.FromJson(nodeGraph.s_nodes[i], type) as Node;
|
||||
nodeGraph.AddNode(node);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nodeGraph.nodes.Count; i++) {
|
||||
nodeGraph.nodes[i].FinalizeDeserialization();
|
||||
if (nodeGraph.nodes != null){
|
||||
for (int i = 0; i < nodeGraph.nodes.Count; i++) {
|
||||
nodeGraph.nodes[i].FinalizeDeserialization();
|
||||
}
|
||||
}
|
||||
return nodeGraph;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user