Added defualt graph properties inspector;

Added sticky note;

Changed the name of BaseNode to SlotContainerNode in case we need other type of nodes in the future;
This commit is contained in:
Misaki
2024-11-04 01:02:30 +09:00
parent 5a9d8b9420
commit 7eec130b39
53 changed files with 517 additions and 436 deletions

View File

@@ -13,7 +13,7 @@ namespace Misaki.GraphView.Sample
{
}
public void Execute(ReadOnlyCollection<BaseNode> nodes)
public void Execute(ReadOnlyCollection<SlotContainerNode> nodes)
{
_isRunning = true;
nodes.ClearAllExecuteFlag();

View File

@@ -7,24 +7,29 @@ namespace Misaki.GraphView.Sample
{
private readonly List<string> _logs = new ();
public Action<BaseNode, string, LogType> OnLog { get; set; }
public Action<SlotContainerNode, string, LogType> OnLog { get; set; }
public void LogInfo(BaseNode node, string message)
public void LogInfo(SlotContainerNode 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)
public void LogWarning(SlotContainerNode 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)
public void LogError(SlotContainerNode node, string message)
{
_logs.Add($"Log Error from node {node.GetType().Name}: {message}");
OnLog?.Invoke(node, message, LogType.Error);
}
public void ClearLogs()
{
_logs.Clear();
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17b084c90754ea04595455524a3e6286
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
#if UNITY_EDITOR
using Misaki.GraphView.Editor;
#endif
namespace Misaki.GraphView.Sample
{
[NodeInfo("Add", "Math")]
public class AddNode : BackTraceNode
{
[NodeInput]
#if UNITY_EDITOR
[InspectorInput]
#endif
public float a;
[NodeInput]
#if UNITY_EDITOR
[InspectorInput]
#endif
public float b;
[NodeOutput]
private float _result;
protected override bool OnExecute()
{
_result = a + b;
return true;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fe1c51aa37dba09468a65f5594146083

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eb7bc6eed66a1dd4ca8c71908a3b3874
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
namespace Misaki.GraphView.Sample
{
public abstract class BackTraceNode : SlotContainerNode
{
protected override void OnPullData(Slot input)
{
if (input.LinkedSlotData.Count == 0)
{
return;
}
var outputNode = GraphObject.GetNode(input.LinkedSlotData[0].nodeID);
outputNode.Execute();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a761276bd0f3a4a4cb4b0894d193f4cd

View File

@@ -0,0 +1,18 @@
using UnityEngine;
namespace Misaki.GraphView.Sample
{
[NodeInfo("Output Node", "Output")]
public class OutputNode : BackTraceNode
{
[NodeInput]
private float _input;
protected override bool OnExecute()
{
GraphObject.Logger.LogInfo(this, $"{_input}");
return true;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 42ed2641b4fc11240be0abda76236178