Added IExecutable and ISlotContainer interface.

Changed SlotContainerNode to ExecutableNode
This commit is contained in:
Misaki
2024-11-05 02:25:15 +09:00
parent 7eec130b39
commit c853994bf5
51 changed files with 443 additions and 400 deletions

View File

@@ -13,10 +13,9 @@ MonoBehaviour:
m_Name: GraphAsset
m_EditorClassIdentifier:
_nodes:
- rid: 299037523270959196
- rid: 299037523270959197
- rid: 299037523270959199
- rid: 299037535202443351
- rid: 299037570321612880
- rid: 299037570321612881
- rid: 299037570321612882
_stickyNotes:
- _id: 940a3025-e571-4b33-8d7c-c86761a95017
title: Title
@@ -30,42 +29,30 @@ MonoBehaviour:
theme: 0
fontSize: 1
_connections:
- _inputSlotData:
slotName: _input
nodeID: 1d18af80-6a54-4cdc-b49c-b53e74f56404
slotIndex: 0
direction: 0
valueType: System.Single
_outputSlotData:
slotName: _result
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 1
valueType: System.Single
- _inputSlotData:
slotName: a
nodeID: b055be5b-5e72-4715-8981-d38913599762
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 0
valueType: System.Single
_outputSlotData:
slotName: value
nodeID: 7a3d7992-0465-458a-bbd8-e972d77b1e34
nodeID: 5ee073fb-e411-4061-867a-9ce3afd9a188
slotIndex: 0
direction: 1
valueType: System.Object
- _inputSlotData:
slotName: _input
nodeID: e630425e-5b42-4839-9e4a-9b134c1e497c
slotIndex: 0
direction: 0
valueType: System.Single
_outputSlotData:
slotName: _result
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
slotIndex: 0
direction: 1
valueType: System.Single
- _inputSlotData:
slotName: a
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
slotIndex: 0
direction: 0
valueType: System.Single
_outputSlotData:
slotName: _result
nodeID: b055be5b-5e72-4715-8981-d38913599762
slotIndex: 0
direction: 1
valueType: System.Single
_exposedProperties:
- rid: 299037523270959195
graphPosition: {x: 72, y: 28.666666, z: 0}
@@ -81,163 +68,111 @@ MonoBehaviour:
propertyType: Misaki.GraphView.Sample.FloatProperty
showInInspector: 1
value: 1
- rid: 299037523270959196
type: {class: PropertyInputNode, ns: Misaki.GraphView, asm: GraphView}
- rid: 299037570321612880
type: {class: Add, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
data:
_inputs: []
_outputs:
- _linkedSlotData:
- slotName: a
nodeID: b055be5b-5e72-4715-8981-d38913599762
slotIndex: 0
direction: 0
valueType: System.Single
owner:
rid: 299037523270959196
slotData:
slotName: value
nodeID: 7a3d7992-0465-458a-bbd8-e972d77b1e34
slotIndex: 0
direction: 1
valueType: System.Object
_graphObject: {fileID: 11400000}
_id: 7a3d7992-0465-458a-bbd8-e972d77b1e34
graphObject: {fileID: 11400000}
id: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
position:
serializedVersion: 2
x: 328.66666
y: 503.99997
width: 98.66666
height: 36
_property:
rid: 299037523270959195
- rid: 299037523270959197
type: {class: OutputNode, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
data:
_inputs:
- _linkedSlotData:
- slotName: _result
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
slotIndex: 0
direction: 1
valueType: System.Single
owner:
rid: 299037523270959197
slotData:
slotName: _input
nodeID: e630425e-5b42-4839-9e4a-9b134c1e497c
slotIndex: 0
direction: 0
valueType: System.Single
_outputs: []
_graphObject: {fileID: 11400000}
_id: e630425e-5b42-4839-9e4a-9b134c1e497c
position:
serializedVersion: 2
x: 847.9999
y: 437.3332
width: 124.66669
height: 78.66666
- rid: 299037523270959199
type: {class: AddNode, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
data:
x: 534
y: 418
width: 116.66669
height: 102.66666
_inputs:
- _linkedSlotData:
- slotName: value
nodeID: 7a3d7992-0465-458a-bbd8-e972d77b1e34
nodeID: 5ee073fb-e411-4061-867a-9ce3afd9a188
slotIndex: 0
direction: 1
valueType: System.Object
owner:
rid: 299037523270959199
rid: 299037570321612880
slotData:
slotName: a
nodeID: b055be5b-5e72-4715-8981-d38913599762
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 0
valueType: System.Single
- _linkedSlotData: []
owner:
rid: 299037523270959199
rid: 299037570321612880
slotData:
slotName: b
nodeID: b055be5b-5e72-4715-8981-d38913599762
slotIndex: 1
direction: 0
valueType: System.Single
_outputs:
- _linkedSlotData:
- slotName: a
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
slotIndex: 0
direction: 0
valueType: System.Single
owner:
rid: 299037523270959199
slotData:
slotName: _result
nodeID: b055be5b-5e72-4715-8981-d38913599762
slotIndex: 0
direction: 1
valueType: System.Single
_graphObject: {fileID: 11400000}
_id: b055be5b-5e72-4715-8981-d38913599762
position:
serializedVersion: 2
x: 495.33328
y: 437.3333
width: 116.66666
height: 102.66666
a: 1
b: 0
- rid: 299037535202443351
type: {class: AddNode, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
data:
_inputs:
- _linkedSlotData:
- slotName: _result
nodeID: b055be5b-5e72-4715-8981-d38913599762
slotIndex: 0
direction: 1
valueType: System.Single
owner:
rid: 299037535202443351
slotData:
slotName: a
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
slotIndex: 0
direction: 0
valueType: System.Single
- _linkedSlotData: []
owner:
rid: 299037535202443351
slotData:
slotName: b
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 1
direction: 0
valueType: System.Single
_outputs:
- _linkedSlotData:
- slotName: _input
nodeID: e630425e-5b42-4839-9e4a-9b134c1e497c
nodeID: 1d18af80-6a54-4cdc-b49c-b53e74f56404
slotIndex: 0
direction: 0
valueType: System.Single
owner:
rid: 299037535202443351
rid: 299037570321612880
slotData:
slotName: _result
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 1
valueType: System.Single
_graphObject: {fileID: 11400000}
_id: c45162b3-f131-44ac-a36f-26b579c4626c
a: 0
b: 0
- rid: 299037570321612881
type: {class: Output, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
data:
graphObject: {fileID: 11400000}
id: 1d18af80-6a54-4cdc-b49c-b53e74f56404
position:
serializedVersion: 2
x: 679.3334
y: 437.3333
width: 116.66669
height: 102.66666
a: 1
b: 0
x: 760
y: 418
width: 124.66669
height: 78.66666
_inputs:
- _linkedSlotData:
- slotName: _result
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 1
valueType: System.Single
owner:
rid: 299037570321612881
slotData:
slotName: _input
nodeID: 1d18af80-6a54-4cdc-b49c-b53e74f56404
slotIndex: 0
direction: 0
valueType: System.Single
_outputs: []
- rid: 299037570321612882
type: {class: PropertyInput, ns: Misaki.GraphView, asm: GraphView}
data:
graphObject: {fileID: 11400000}
id: 5ee073fb-e411-4061-867a-9ce3afd9a188
position:
serializedVersion: 2
x: 335.3333
y: 484.6667
width: 98.66666
height: 36
_inputs: []
_outputs:
- _linkedSlotData:
- slotName: a
nodeID: 31f46c9e-45f1-418a-bb4b-cc843ea9242a
slotIndex: 0
direction: 0
valueType: System.Single
owner:
rid: 299037570321612882
slotData:
slotName: value
nodeID: 5ee073fb-e411-4061-867a-9ce3afd9a188
slotIndex: 0
direction: 1
valueType: System.Object
_property:
rid: 299037523270959195

View File

@@ -13,14 +13,14 @@ namespace Misaki.GraphView.Sample
{
}
public void Execute(ReadOnlyCollection<SlotContainerNode> nodes)
public void Execute(ReadOnlyCollection<DataNode> nodes)
{
_isRunning = true;
nodes.ClearAllExecuteFlag();
foreach (var node in nodes)
{
if (node is OutputNode outputNode)
if (node is Output outputNode)
{
outputNode.Execute();
}

View File

@@ -7,21 +7,21 @@ namespace Misaki.GraphView.Sample
{
private readonly List<string> _logs = new ();
public Action<SlotContainerNode, string, LogType> OnLog { get; set; }
public Action<ExecutableNode, string, LogType> OnLog { get; set; }
public void LogInfo(SlotContainerNode node, string message)
public void LogInfo(ExecutableNode node, string message)
{
_logs.Add($"Log Info from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Info);
}
public void LogWarning(SlotContainerNode node, string message)
public void LogWarning(ExecutableNode node, string message)
{
_logs.Add($"Log Warning from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Warning);
}
public void LogError(SlotContainerNode node, string message)
public void LogError(ExecutableNode node, string message)
{
_logs.Add($"Log Error from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Error);

View File

@@ -5,7 +5,7 @@ using Misaki.GraphView.Editor;
namespace Misaki.GraphView.Sample
{
[NodeInfo("Add", "Math")]
public class AddNode : BackTraceNode
public class Add : BackTraceExecutableNode
{
[NodeInput]
#if UNITY_EDITOR

View File

@@ -1,6 +1,6 @@
namespace Misaki.GraphView.Sample
{
public abstract class BackTraceNode : SlotContainerNode
public abstract class BackTraceExecutableNode : ExecutableNode
{
protected override void OnPullData(Slot input)
{
@@ -10,7 +10,10 @@ namespace Misaki.GraphView.Sample
}
var outputNode = GraphObject.GetNode(input.LinkedSlotData[0].nodeID);
outputNode.Execute();
if (outputNode is IExecutable executable)
{
executable.Execute();
}
}
}
}

View File

@@ -3,7 +3,7 @@ using UnityEngine;
namespace Misaki.GraphView.Sample
{
[NodeInfo("Output Node", "Output")]
public class OutputNode : BackTraceNode
public class Output : BackTraceExecutableNode
{
[NodeInput]
private float _input;