mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Fixed open empty NodeGraph
This commit is contained in:
parent
9ef6069ea7
commit
d237e1529b
@ -72,6 +72,11 @@ public class NodeGraph {
|
|||||||
|
|
||||||
public static NodeGraph Deserialize(string json) {
|
public static NodeGraph Deserialize(string json) {
|
||||||
NodeGraph nodeGraph = JsonUtility.FromJson<NodeGraph>(json);
|
NodeGraph nodeGraph = JsonUtility.FromJson<NodeGraph>(json);
|
||||||
|
|
||||||
|
//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++) {
|
for (int i = 0; i < nodeGraph.s_nodes.Length; i++) {
|
||||||
NodeTyper tempNode = new NodeTyper();
|
NodeTyper tempNode = new NodeTyper();
|
||||||
JsonUtility.FromJsonOverwrite(nodeGraph.s_nodes[i], tempNode);
|
JsonUtility.FromJsonOverwrite(nodeGraph.s_nodes[i], tempNode);
|
||||||
@ -80,9 +85,12 @@ public class NodeGraph {
|
|||||||
Node node = JsonUtility.FromJson(nodeGraph.s_nodes[i], type) as Node;
|
Node node = JsonUtility.FromJson(nodeGraph.s_nodes[i], type) as Node;
|
||||||
nodeGraph.AddNode(node);
|
nodeGraph.AddNode(node);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (nodeGraph.nodes != null){
|
||||||
for (int i = 0; i < nodeGraph.nodes.Count; i++) {
|
for (int i = 0; i < nodeGraph.nodes.Count; i++) {
|
||||||
nodeGraph.nodes[i].FinalizeDeserialization();
|
nodeGraph.nodes[i].FinalizeDeserialization();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nodeGraph;
|
return nodeGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user