1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-21 01:36:03 +08:00

Example changes.

This commit is contained in:
Thor Brigsted 2017-10-29 21:35:01 +01:00
parent cb3424d6eb
commit 199ac1ba78
10 changed files with 103 additions and 97 deletions

View File

@ -12,11 +12,10 @@ MonoBehaviour:
m_Name: ExampleNodeGraph m_Name: ExampleNodeGraph
m_EditorClassIdentifier: m_EditorClassIdentifier:
nodes: nodes:
- {fileID: 114386305456729202} - {fileID: 114729867621534192}
- {fileID: 114862693020615806} - {fileID: 114708853913061688}
- {fileID: 114245132648392102} - {fileID: 114511978881715272}
- {fileID: 114602227203521556} --- !u!114 &114511978881715272
--- !u!114 &114245132648392102
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
@ -24,34 +23,32 @@ MonoBehaviour:
m_GameObject: {fileID: 0} m_GameObject: {fileID: 0}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 22e05e2a1f5ad7645850d52212143629, type: 3} m_Script: {fileID: 11500000, guid: 19e541bba2a188f4a84c6f3718ee6d55, type: 3}
m_Name: MathNode m_Name: MathNode
m_EditorClassIdentifier: m_EditorClassIdentifier:
graph: {fileID: 11400000} graph: {fileID: 11400000}
position: {x: -429.5, y: -110.5} position: {x: -539.5, y: -205}
inputs: inputs:
- node: {fileID: 114245132648392102} - node: {fileID: 114511978881715272}
_fieldName: a _fieldName: a
connections: [] connections: []
_direction: 0 _direction: 0
- node: {fileID: 114245132648392102} - node: {fileID: 114511978881715272}
_fieldName: b _fieldName: b
connections: [] connections: []
_direction: 0 _direction: 0
outputs: outputs:
- node: {fileID: 114245132648392102} - node: {fileID: 114511978881715272}
_fieldName: result _fieldName: result
connections: connections:
- fieldName: a - fieldName: x
node: {fileID: 114862693020615806} node: {fileID: 114708853913061688}
- fieldName: value
node: {fileID: 114602227203521556}
_direction: 1 _direction: 1
a: 4.771955 a: 2.7975256
b: 8.313191 b: 6.7917466
result: 0 result: 0
mathType: 0 mathType: 0
--- !u!114 &114386305456729202 --- !u!114 &114708853913061688
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
@ -59,74 +56,55 @@ MonoBehaviour:
m_GameObject: {fileID: 0} m_GameObject: {fileID: 0}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 98f6f901f0da53142b79277ea3f42518, type: 3} m_Script: {fileID: 11500000, guid: 05559f4106850df4ab41776666216480, type: 3}
m_Name: DisplayValue m_Name: Vector
m_EditorClassIdentifier: m_EditorClassIdentifier:
graph: {fileID: 11400000} graph: {fileID: 11400000}
position: {x: 23.5, y: -98.5} position: {x: -157.5, y: -115}
inputs: inputs:
- node: {fileID: 114386305456729202} - node: {fileID: 114708853913061688}
_fieldName: value _fieldName: x
connections: connections:
- fieldName: result - fieldName: result
node: {fileID: 114862693020615806} node: {fileID: 114511978881715272}
_direction: 0 _direction: 0
outputs: [] - node: {fileID: 114708853913061688}
value: 4.01703 _fieldName: y
--- !u!114 &114602227203521556 connections: []
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}
_direction: 0 _direction: 0
outputs: [] - node: {fileID: 114708853913061688}
value: 0 _fieldName: z
--- !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
connections: [] connections: []
_direction: 0 _direction: 0
outputs: outputs:
- node: {fileID: 114862693020615806} - node: {fileID: 114708853913061688}
_fieldName: result _fieldName: vector
connections: connections:
- fieldName: value - fieldName: value
node: {fileID: 114386305456729202} node: {fileID: 114729867621534192}
_direction: 1 _direction: 1
a: 8.142139 x: 0
b: 3.53361 y: 2.6412349
result: 0 z: 14.33477
mathType: 1 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: []

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 614b670274b902e44bba59ba861eb1bd guid: cee47fa32ae90bb4f8f0bec6f186cb3b
timeCreated: 1507988229 timeCreated: 1509308927
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000
userData: userData:
assetBundleName: assetBundleName:

View File

@ -1,9 +1,9 @@
namespace ExampleNodes { namespace BasicNodes {
public class DisplayValue : Node { public class DisplayValue : Node {
[Input] public float value; [Input(ShowBackingValue.Never)] public object value;
public float GetValue() { public override object GetValue(NodePort port) {
return GetInputByFieldName<float>("value", value); return GetInputByFieldName<object>("value", value);
} }
} }
} }

View File

@ -1,9 +1,10 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0d2300267781fed46a6d964565309cbf guid: 0d2300267781fed46a6d964565309cbf
folderAsset: yes folderAsset: yes
timeCreated: 1505987971 timeCreated: 1509307735
licenseType: Free licenseType: Free
DefaultImporter: DefaultImporter:
externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -1,20 +1,16 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEngine;
namespace ExampleNodes { namespace BasicNodes {
[CustomNodeEditor(typeof(ExampleNodes.DisplayValue), "ExampleNodes/Display Value")] [CustomNodeEditor(typeof(DisplayValue), "BasicNodes/DisplayValue")]
public class DisplayValueEditor : NodeEditor { public class DisplayValueEditor : NodeEditor {
protected override void OnBodyGUI(out Dictionary<NodePort, Vector2> portPositions) { protected override void OnBodyGUI(out Dictionary<NodePort, Vector2> portPositions) {
base.OnBodyGUI(out portPositions); base.OnBodyGUI(out portPositions);
EditorGUILayout.LabelField(GetResult().ToString()); object obj = target.GetValue(null);
} if (obj != null) EditorGUILayout.LabelField(target.GetValue(null).ToString());
public float GetResult() {
DisplayValue t = target as DisplayValue;
return t.GetValue();
} }
} }
} }

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 429e0671aa9024e449642837aeadc9c2 guid: 7d7298690665789498dc42a285eb2c28
timeCreated: 1507499229 timeCreated: 1509305659
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0

View File

@ -1,4 +1,4 @@
namespace ExampleNodes { namespace BasicNodes {
[System.Serializable] [System.Serializable]
public class MathNode : Node { 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 // Adding [Input] or [Output] is all you need to do to register a field as a valid port on your node

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 22e05e2a1f5ad7645850d52212143629 guid: 19e541bba2a188f4a84c6f3718ee6d55
timeCreated: 1505937586 timeCreated: 1509307779
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0

15
Example/Nodes/Vector.cs Normal file
View File

@ -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<float>("x", this.x);
float y = GetInputByFieldName<float>("y", this.y);
float z = GetInputByFieldName<float>("z", this.z);
return new Vector3(x, y, z);
}
}
}

View File

@ -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: