diff --git a/Example/ExampleNodeGraph.asset b/Example/ExampleNodeGraph.asset index 2215cf0..1506893 100644 --- a/Example/ExampleNodeGraph.asset +++ b/Example/ExampleNodeGraph.asset @@ -12,11 +12,10 @@ MonoBehaviour: m_Name: ExampleNodeGraph m_EditorClassIdentifier: nodes: - - {fileID: 114386305456729202} - - {fileID: 114862693020615806} - - {fileID: 114245132648392102} - - {fileID: 114602227203521556} ---- !u!114 &114245132648392102 + - {fileID: 114729867621534192} + - {fileID: 114708853913061688} + - {fileID: 114511978881715272} +--- !u!114 &114511978881715272 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} @@ -24,34 +23,32 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 22e05e2a1f5ad7645850d52212143629, type: 3} + m_Script: {fileID: 11500000, guid: 19e541bba2a188f4a84c6f3718ee6d55, type: 3} m_Name: MathNode m_EditorClassIdentifier: graph: {fileID: 11400000} - position: {x: -429.5, y: -110.5} + position: {x: -539.5, y: -205} inputs: - - node: {fileID: 114245132648392102} + - node: {fileID: 114511978881715272} _fieldName: a connections: [] _direction: 0 - - node: {fileID: 114245132648392102} + - node: {fileID: 114511978881715272} _fieldName: b connections: [] _direction: 0 outputs: - - node: {fileID: 114245132648392102} + - node: {fileID: 114511978881715272} _fieldName: result connections: - - fieldName: a - node: {fileID: 114862693020615806} - - fieldName: value - node: {fileID: 114602227203521556} + - fieldName: x + node: {fileID: 114708853913061688} _direction: 1 - a: 4.771955 - b: 8.313191 + a: 2.7975256 + b: 6.7917466 result: 0 mathType: 0 ---- !u!114 &114386305456729202 +--- !u!114 &114708853913061688 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} @@ -59,74 +56,55 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 98f6f901f0da53142b79277ea3f42518, type: 3} - m_Name: DisplayValue + m_Script: {fileID: 11500000, guid: 05559f4106850df4ab41776666216480, type: 3} + m_Name: Vector m_EditorClassIdentifier: graph: {fileID: 11400000} - position: {x: 23.5, y: -98.5} + position: {x: -157.5, y: -115} inputs: - - node: {fileID: 114386305456729202} - _fieldName: value + - node: {fileID: 114708853913061688} + _fieldName: x connections: - fieldName: result - node: {fileID: 114862693020615806} + node: {fileID: 114511978881715272} _direction: 0 - outputs: [] - value: 4.01703 ---- !u!114 &114602227203521556 -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: - graph: {fileID: 11400000} - position: {x: -194.5, y: -140.5} - inputs: - - node: {fileID: 114602227203521556} - _fieldName: value - connections: - - fieldName: result - node: {fileID: 114245132648392102} + - node: {fileID: 114708853913061688} + _fieldName: y + connections: [] _direction: 0 - outputs: [] - value: 0 ---- !u!114 &114862693020615806 -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: MathNode - m_EditorClassIdentifier: - graph: {fileID: 11400000} - position: {x: -196.5, y: -45.5} - inputs: - - node: {fileID: 114862693020615806} - _fieldName: a - connections: - - fieldName: result - node: {fileID: 114245132648392102} - _direction: 0 - - node: {fileID: 114862693020615806} - _fieldName: b + - node: {fileID: 114708853913061688} + _fieldName: z connections: [] _direction: 0 outputs: - - node: {fileID: 114862693020615806} - _fieldName: result + - node: {fileID: 114708853913061688} + _fieldName: vector connections: - fieldName: value - node: {fileID: 114386305456729202} + node: {fileID: 114729867621534192} _direction: 1 - a: 8.142139 - b: 3.53361 - result: 0 - mathType: 1 + x: 0 + y: 2.6412349 + z: 14.33477 + vector: {x: 0, y: 0, z: 0} +--- !u!114 &114729867621534192 +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: + graph: {fileID: 11400000} + position: {x: 78.5, y: -64} + inputs: + - node: {fileID: 114729867621534192} + _fieldName: value + connections: + - fieldName: vector + node: {fileID: 114708853913061688} + _direction: 0 + outputs: [] diff --git a/Example/ExampleNodeGraph.asset.meta b/Example/ExampleNodeGraph.asset.meta index 12fe78e..0ef23bc 100644 --- a/Example/ExampleNodeGraph.asset.meta +++ b/Example/ExampleNodeGraph.asset.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 614b670274b902e44bba59ba861eb1bd -timeCreated: 1507988229 +guid: cee47fa32ae90bb4f8f0bec6f186cb3b +timeCreated: 1509308927 licenseType: Free NativeFormatImporter: + externalObjects: {} mainObjectFileID: 11400000 userData: assetBundleName: diff --git a/Example/Nodes/DisplayValue.cs b/Example/Nodes/DisplayValue.cs index 1e376be..445517a 100644 --- a/Example/Nodes/DisplayValue.cs +++ b/Example/Nodes/DisplayValue.cs @@ -1,9 +1,9 @@ -namespace ExampleNodes { +namespace BasicNodes { public class DisplayValue : Node { - [Input] public float value; + [Input(ShowBackingValue.Never)] public object value; - public float GetValue() { - return GetInputByFieldName("value", value); + public override object GetValue(NodePort port) { + return GetInputByFieldName("value", value); } } } diff --git a/Example/Nodes/Editor.meta b/Example/Nodes/Editor.meta index 40beab9..1008817 100644 --- a/Example/Nodes/Editor.meta +++ b/Example/Nodes/Editor.meta @@ -1,9 +1,10 @@ fileFormatVersion: 2 guid: 0d2300267781fed46a6d964565309cbf folderAsset: yes -timeCreated: 1505987971 +timeCreated: 1509307735 licenseType: Free DefaultImporter: + externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Example/Nodes/Editor/DisplayValueEditor.cs b/Example/Nodes/Editor/DisplayValueEditor.cs index c2a4366..0cc8af5 100644 --- a/Example/Nodes/Editor/DisplayValueEditor.cs +++ b/Example/Nodes/Editor/DisplayValueEditor.cs @@ -1,20 +1,16 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; using UnityEditor; +using UnityEngine; -namespace ExampleNodes { - [CustomNodeEditor(typeof(ExampleNodes.DisplayValue), "ExampleNodes/Display Value")] +namespace BasicNodes { + [CustomNodeEditor(typeof(DisplayValue), "BasicNodes/DisplayValue")] public class DisplayValueEditor : NodeEditor { protected override void OnBodyGUI(out Dictionary portPositions) { base.OnBodyGUI(out portPositions); - EditorGUILayout.LabelField(GetResult().ToString()); - } - - public float GetResult() { - DisplayValue t = target as DisplayValue; - return t.GetValue(); + object obj = target.GetValue(null); + if (obj != null) EditorGUILayout.LabelField(target.GetValue(null).ToString()); } } -} +} \ No newline at end of file diff --git a/Example/Nodes/Editor/DisplayValueEditor.cs.meta b/Example/Nodes/Editor/DisplayValueEditor.cs.meta index 15cde80..971da18 100644 --- a/Example/Nodes/Editor/DisplayValueEditor.cs.meta +++ b/Example/Nodes/Editor/DisplayValueEditor.cs.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 429e0671aa9024e449642837aeadc9c2 -timeCreated: 1507499229 +guid: 7d7298690665789498dc42a285eb2c28 +timeCreated: 1509305659 licenseType: Free MonoImporter: + externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/Example/Nodes/MathNode.cs b/Example/Nodes/MathNode.cs index 65856f9..564c4e8 100644 --- a/Example/Nodes/MathNode.cs +++ b/Example/Nodes/MathNode.cs @@ -1,4 +1,4 @@ -namespace ExampleNodes { +namespace BasicNodes { [System.Serializable] public class MathNode : Node { // Adding [Input] or [Output] is all you need to do to register a field as a valid port on your node diff --git a/Example/Nodes/MathNode.cs.meta b/Example/Nodes/MathNode.cs.meta index 118fe96..bd2894c 100644 --- a/Example/Nodes/MathNode.cs.meta +++ b/Example/Nodes/MathNode.cs.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 22e05e2a1f5ad7645850d52212143629 -timeCreated: 1505937586 +guid: 19e541bba2a188f4a84c6f3718ee6d55 +timeCreated: 1509307779 licenseType: Free MonoImporter: + externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/Example/Nodes/Vector.cs b/Example/Nodes/Vector.cs new file mode 100644 index 0000000..804f087 --- /dev/null +++ b/Example/Nodes/Vector.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace BasicNodes { + public class Vector : Node { + [Input] public float x, y, z; + [Output] public Vector3 vector; + + public override object GetValue(NodePort port) { + float x = GetInputByFieldName("x", this.x); + float y = GetInputByFieldName("y", this.y); + float z = GetInputByFieldName("z", this.z); + return new Vector3(x, y, z); + } + } +} \ No newline at end of file diff --git a/Example/Nodes/Vector.cs.meta b/Example/Nodes/Vector.cs.meta new file mode 100644 index 0000000..968b1f6 --- /dev/null +++ b/Example/Nodes/Vector.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 05559f4106850df4ab41776666216480 +timeCreated: 1509303406 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: