mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 09:46:03 +08:00
Serialization now works correctly. Removal of nodes still broken
This commit is contained in:
parent
8ce0d63903
commit
3dae0910dc
@ -1,69 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: a6399826e2c44b447b32a3ed06646162, type: 3}
|
|
||||||
m_Name: ExampleNodeGraph
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
nodes:
|
|
||||||
- {fileID: 114169009298143184}
|
|
||||||
- {fileID: 114520184832602068}
|
|
||||||
--- !u!114 &114169009298143184
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 98f6f901f0da53142b79277ea3f42518, type: 3}
|
|
||||||
m_Name: DisplayValue
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
rect:
|
|
||||||
serializedVersion: 2
|
|
||||||
x: 130
|
|
||||||
y: 6
|
|
||||||
width: 200
|
|
||||||
height: 200
|
|
||||||
inputs:
|
|
||||||
- _fieldName: value
|
|
||||||
connections:
|
|
||||||
- node: {fileID: 114520184832602068}
|
|
||||||
fieldName: result
|
|
||||||
_direction: 0
|
|
||||||
outputs: []
|
|
||||||
value: 0
|
|
||||||
--- !u!114 &114520184832602068
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 22e05e2a1f5ad7645850d52212143629, type: 3}
|
|
||||||
m_Name: Math
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
rect:
|
|
||||||
serializedVersion: 2
|
|
||||||
x: -176
|
|
||||||
y: 96
|
|
||||||
width: 200
|
|
||||||
height: 200
|
|
||||||
inputs: []
|
|
||||||
outputs:
|
|
||||||
- _fieldName: result
|
|
||||||
connections:
|
|
||||||
- node: {fileID: 114169009298143184}
|
|
||||||
fieldName: value
|
|
||||||
_direction: 1
|
|
||||||
a: 0
|
|
||||||
b: 0
|
|
||||||
result: 0
|
|
||||||
mathType: 0
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2c7ed5ea36166484a8bcecda71ad8cc8
|
|
||||||
timeCreated: 1507760054
|
|
||||||
licenseType: Free
|
|
||||||
NativeFormatImporter:
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -20,7 +20,6 @@ public class DisplayValueEditor : NodeEditor {
|
|||||||
|
|
||||||
NodePort connection = port.GetConnection(i);
|
NodePort connection = port.GetConnection(i);
|
||||||
if (connection == null) continue;
|
if (connection == null) continue;
|
||||||
|
|
||||||
object obj = connection.GetValue();
|
object obj = connection.GetValue();
|
||||||
if (obj == null) continue;
|
if (obj == null) continue;
|
||||||
|
|
||||||
|
|||||||
@ -41,21 +41,19 @@ public abstract class Node : ScriptableObject {
|
|||||||
else return GetInputByFieldName(fieldName);
|
else return GetInputByFieldName(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Returns output port which matches fieldName </summary>
|
/// <summary> Returns output port which matches fieldName. Returns null if none found. </summary>
|
||||||
public NodePort GetOutputByFieldName(string fieldName) {
|
public NodePort GetOutputByFieldName(string fieldName) {
|
||||||
for (int i = 0; i < OutputCount; i++) {
|
for (int i = 0; i < OutputCount; i++) {
|
||||||
if (outputs[i].fieldName == fieldName) return outputs[i];
|
if (outputs[i].fieldName == fieldName) return outputs[i];
|
||||||
}
|
}
|
||||||
Debug.LogWarning("No outputs with fieldName '" + fieldName+"'");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Returns input port which matches fieldName </summary>
|
/// <summary> Returns input port which matches. Returns null if none found. </summary>
|
||||||
public NodePort GetInputByFieldName(string fieldName) {
|
public NodePort GetInputByFieldName(string fieldName) {
|
||||||
for (int i = 0; i < InputCount; i++) {
|
for (int i = 0; i < InputCount; i++) {
|
||||||
if (inputs[i].fieldName == fieldName) return inputs[i];
|
if (inputs[i].fieldName == fieldName) return inputs[i];
|
||||||
}
|
}
|
||||||
Debug.LogWarning("No inputs with fieldName '" + fieldName+"'");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,17 +49,17 @@ public abstract class NodeGraph : ScriptableObject, ISerializationCallbackReceiv
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void OnAfterDeserialize() {
|
public void OnAfterDeserialize() {
|
||||||
for (int i = 0; i < nodes.Count; i++) {
|
/*for (int i = 0; i < nodes.Count; i++) {
|
||||||
nodes[i].graph = this;
|
nodes[i].graph = this;
|
||||||
}
|
}*/
|
||||||
VerifyConnections();
|
//VerifyConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Checks all connections for invalid references, and removes them. </summary>
|
/*/// <summary> Checks all connections for invalid references, and removes them. </summary>
|
||||||
public void VerifyConnections() {
|
public void VerifyConnections() {
|
||||||
for (int i = 0; i < nodes.Count; i++) {
|
for (int i = 0; i < nodes.Count; i++) {
|
||||||
nodes[i].VerifyConnections();
|
nodes[i].VerifyConnections();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,10 +18,10 @@ public class NodePort {
|
|||||||
public bool IsInput { get { return direction == IO.Input; } }
|
public bool IsInput { get { return direction == IO.Input; } }
|
||||||
public bool IsOutput { get { return direction == IO.Output; } }
|
public bool IsOutput { get { return direction == IO.Output; } }
|
||||||
|
|
||||||
public Node node { get; private set; }
|
|
||||||
public string fieldName { get { return _fieldName; } }
|
public string fieldName { get { return _fieldName; } }
|
||||||
|
|
||||||
|
|
||||||
|
[SerializeField] public Node node;
|
||||||
[SerializeField] private string _fieldName;
|
[SerializeField] private string _fieldName;
|
||||||
[SerializeField] public Type type;
|
[SerializeField] public Type type;
|
||||||
[SerializeField] private List<PortConnection> connections = new List<PortConnection>();
|
[SerializeField] private List<PortConnection> connections = new List<PortConnection>();
|
||||||
@ -77,7 +77,8 @@ public class NodePort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NodePort GetConnection(int i) {
|
public NodePort GetConnection(int i) {
|
||||||
return connections[i].Port;
|
NodePort port = connections[i].node.GetPortByFieldName(connections[i].fieldName);
|
||||||
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConnectedTo(NodePort port) {
|
public bool IsConnectedTo(NodePort port) {
|
||||||
@ -108,8 +109,8 @@ public class NodePort {
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class PortConnection {
|
public class PortConnection {
|
||||||
[SerializeField] public Node node;
|
|
||||||
[SerializeField] public string fieldName;
|
[SerializeField] public string fieldName;
|
||||||
|
[SerializeField] public Node node;
|
||||||
public NodePort Port { get { return port != null ? port : port = GetPort(); } }
|
public NodePort Port { get { return port != null ? port : port = GetPort(); } }
|
||||||
[NonSerialized] private NodePort port;
|
[NonSerialized] private NodePort port;
|
||||||
|
|
||||||
@ -120,6 +121,7 @@ public class NodePort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NodePort GetPort() {
|
private NodePort GetPort() {
|
||||||
|
|
||||||
for (int i = 0; i < node.OutputCount; i++) {
|
for (int i = 0; i < node.OutputCount; i++) {
|
||||||
if (node.outputs[i].fieldName == fieldName) return node.outputs[i];
|
if (node.outputs[i].fieldName == fieldName) return node.outputs[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user