Add new feature.
Added ILogger; Added IGraphProcessor; Changed return type of OnExecute method in BaseNode from void to bool;
This commit is contained in:
@@ -16,6 +16,7 @@ MonoBehaviour:
|
||||
- rid: 299037523270959196
|
||||
- rid: 299037523270959197
|
||||
- rid: 299037523270959199
|
||||
- rid: 299037535202443351
|
||||
_connections:
|
||||
- _inputSlotData:
|
||||
slotName: a
|
||||
@@ -35,6 +36,18 @@ MonoBehaviour:
|
||||
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
|
||||
@@ -43,8 +56,8 @@ MonoBehaviour:
|
||||
valueType: System.Single
|
||||
_exposedProperties:
|
||||
- rid: 299037523270959195
|
||||
graphPosition: {x: -119.333336, y: -80.666664, z: 0}
|
||||
graphScale: {x: 1.331, y: 1.331, z: 1}
|
||||
graphPosition: {x: -76.666664, y: -113.333336, z: 0}
|
||||
graphScale: {x: 1.21, y: 1.21, z: 1}
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
@@ -90,7 +103,7 @@ MonoBehaviour:
|
||||
_inputs:
|
||||
- _linkedSlotData:
|
||||
- slotName: _result
|
||||
nodeID: b055be5b-5e72-4715-8981-d38913599762
|
||||
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
|
||||
slotIndex: 0
|
||||
direction: 1
|
||||
valueType: System.Single
|
||||
@@ -107,9 +120,9 @@ MonoBehaviour:
|
||||
_id: e630425e-5b42-4839-9e4a-9b134c1e497c
|
||||
position:
|
||||
serializedVersion: 2
|
||||
x: 699.3334
|
||||
x: 840.6667
|
||||
y: 437.3333
|
||||
width: 124.666626
|
||||
width: 124.66669
|
||||
height: 78.66666
|
||||
- rid: 299037523270959199
|
||||
type: {class: AddNode, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
|
||||
@@ -140,8 +153,8 @@ MonoBehaviour:
|
||||
valueType: System.Single
|
||||
_outputs:
|
||||
- _linkedSlotData:
|
||||
- slotName: _input
|
||||
nodeID: e630425e-5b42-4839-9e4a-9b134c1e497c
|
||||
- slotName: a
|
||||
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
|
||||
slotIndex: 0
|
||||
direction: 0
|
||||
valueType: System.Single
|
||||
@@ -161,5 +174,57 @@ MonoBehaviour:
|
||||
y: 437.76617
|
||||
width: 0
|
||||
height: 0
|
||||
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
|
||||
slotIndex: 1
|
||||
direction: 0
|
||||
valueType: System.Single
|
||||
_outputs:
|
||||
- _linkedSlotData:
|
||||
- slotName: _input
|
||||
nodeID: e630425e-5b42-4839-9e4a-9b134c1e497c
|
||||
slotIndex: 0
|
||||
direction: 0
|
||||
valueType: System.Single
|
||||
owner:
|
||||
rid: 299037535202443351
|
||||
slotData:
|
||||
slotName: _result
|
||||
nodeID: c45162b3-f131-44ac-a36f-26b579c4626c
|
||||
slotIndex: 0
|
||||
direction: 1
|
||||
valueType: System.Single
|
||||
_graphObject: {fileID: 11400000}
|
||||
_id: c45162b3-f131-44ac-a36f-26b579c4626c
|
||||
position:
|
||||
serializedVersion: 2
|
||||
x: 673.3334
|
||||
y: 437.3333
|
||||
width: 116.666626
|
||||
height: 102.66666
|
||||
a: 0
|
||||
b: 1
|
||||
b: 0
|
||||
|
||||
3
Sample/Runtime/Models.meta
Normal file
3
Sample/Runtime/Models.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a05fdef25de94879a769c2dc457bd59e
|
||||
timeCreated: 1730561124
|
||||
35
Sample/Runtime/Models/BackTraceGraphProcessor.cs
Normal file
35
Sample/Runtime/Models/BackTraceGraphProcessor.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Misaki.GraphView.Sample
|
||||
{
|
||||
public class BackTraceGraphProcessor : IGraphProcessor
|
||||
{
|
||||
private bool _isRunning;
|
||||
|
||||
public bool IsRunning => _isRunning;
|
||||
|
||||
public void UpdateComputeOrder()
|
||||
{
|
||||
}
|
||||
|
||||
public void Execute(ReadOnlyCollection<BaseNode> nodes)
|
||||
{
|
||||
_isRunning = true;
|
||||
nodes.ClearAllExecuteFlag();
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (node is OutputNode outputNode)
|
||||
{
|
||||
outputNode.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Break()
|
||||
{
|
||||
_isRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Sample/Runtime/Models/BackTraceGraphProcessor.cs.meta
Normal file
3
Sample/Runtime/Models/BackTraceGraphProcessor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13065a6e26d040a4b3e73e1d66e6cf4f
|
||||
timeCreated: 1730564245
|
||||
30
Sample/Runtime/Models/Logger.cs
Normal file
30
Sample/Runtime/Models/Logger.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Misaki.GraphView.Sample
|
||||
{
|
||||
public class Logger : ILogger
|
||||
{
|
||||
private readonly List<string> _logs = new ();
|
||||
|
||||
public Action<BaseNode, string, LogType> OnLog { get; set; }
|
||||
|
||||
public void LogInfo(BaseNode node, string message)
|
||||
{
|
||||
_logs.Add($"Log Info from node {node.GetType().Name}: {message}");
|
||||
OnLog?.Invoke(node, message, LogType.Info);
|
||||
}
|
||||
|
||||
public void LogWarning(BaseNode node, string message)
|
||||
{
|
||||
_logs.Add($"Log Warning from node {node.GetType().Name}: {message}");
|
||||
OnLog?.Invoke(node, message, LogType.Warning);
|
||||
}
|
||||
|
||||
public void LogError(BaseNode node, string message)
|
||||
{
|
||||
_logs.Add($"Log Error from node {node.GetType().Name}: {message}");
|
||||
OnLog?.Invoke(node, message, LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Sample/Runtime/Models/Logger.cs.meta
Normal file
3
Sample/Runtime/Models/Logger.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da3c5b7d66754f948efd7f895b5a4b21
|
||||
timeCreated: 1730561133
|
||||
@@ -22,9 +22,11 @@ namespace Misaki.GraphView.Sample
|
||||
[NodeOutput]
|
||||
private float _result;
|
||||
|
||||
protected override void OnExecute()
|
||||
protected override bool OnExecute()
|
||||
{
|
||||
_result = a + b;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ namespace Misaki.GraphView.Sample
|
||||
[NodeInput]
|
||||
private float _input;
|
||||
|
||||
protected override void OnExecute()
|
||||
protected override bool OnExecute()
|
||||
{
|
||||
Debug.Log(_input);
|
||||
GraphObject.Logger.LogInfo(this, $"{_input}");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,10 @@ namespace Misaki.GraphView.Sample
|
||||
[CreateAssetMenu(fileName = "GraphAsset", menuName = "Scriptable Objects/GraphAsset")]
|
||||
public class SampleGraphAsset : GraphObject
|
||||
{
|
||||
public override void Execute()
|
||||
{
|
||||
Nodes.ClearAllExecuteFlag();
|
||||
|
||||
foreach (var node in Nodes)
|
||||
{
|
||||
if (node is OutputNode outputNode)
|
||||
{
|
||||
outputNode.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
private readonly Logger _logger = new Logger();
|
||||
private readonly BackTraceGraphProcessor _processor = new BackTraceGraphProcessor();
|
||||
|
||||
public override ILogger Logger => _logger;
|
||||
public override IGraphProcessor GraphProcessor => _processor;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,19 @@ GridBackground
|
||||
--spacing : 15;
|
||||
}
|
||||
|
||||
EditorNodeView.node-execution-failed VisualElement#node-border
|
||||
{
|
||||
border-bottom-width: 1px;
|
||||
border-top-width: 1px;
|
||||
border-left-width: 1px;
|
||||
border-right-width: 1px;
|
||||
|
||||
border-bottom-color: red;
|
||||
border-top-color: red;
|
||||
border-left-color: red;
|
||||
border-right-color: red;
|
||||
}
|
||||
|
||||
.graphElement.node.math VisualElement#title
|
||||
{
|
||||
background-color : rgba(64, 96, 128, 0.8);
|
||||
|
||||
Reference in New Issue
Block a user