mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 09:46:03 +08:00
Update README.md
This commit is contained in:
parent
554a85cb71
commit
6711846536
24
README.md
24
README.md
@ -10,7 +10,15 @@ UNEC is ideal as a base for custom state machines, dialogue systems, decision ma
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Node example:
|
### Key features of UnityNodeEditorCore:
|
||||||
|
* Lightweight in runtime
|
||||||
|
* Very little boilerplate code
|
||||||
|
* Strong separation of editor and runtime code
|
||||||
|
* No runtime reflection (unless you need to edit/build node graphs at runtime. In this case, all reflection is cached.)
|
||||||
|
* Does not rely on any 3rd party plugins
|
||||||
|
* Custom node inspector code is very similar to regular custom inspector code
|
||||||
|
|
||||||
|
### Node example:
|
||||||
```csharp
|
```csharp
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class MathNode : Node {
|
public class MathNode : Node {
|
||||||
@ -20,8 +28,18 @@ public class MathNode : Node {
|
|||||||
public enum MathType { Add, Subtract, Multiply, Divide}
|
public enum MathType { Add, Subtract, Multiply, Divide}
|
||||||
public MathType mathType = MathType.Add;
|
public MathType mathType = MathType.Add;
|
||||||
|
|
||||||
protected override void Init() {
|
public override object GetValue(NodePort port) {
|
||||||
name = "Math";
|
if (port.fieldName == "result") {
|
||||||
|
float a = GetInputFloat("a");
|
||||||
|
float b = GetInputFloat("b");
|
||||||
|
switch(mathType) {
|
||||||
|
case MathType.Add: return a + b;
|
||||||
|
case MathType.Subtract: return a - b;
|
||||||
|
case MathType.Multiply: return a * b;
|
||||||
|
case MathType.Divide: return a / b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user