Changed Slot in RelayNode to ProxySlot;
Changed PullData and PushData from SlotExtension to ISlot; Added BackTraceExecutableNode; Removed IExecutable from RelayNode;
This commit is contained in:
@@ -11,8 +11,14 @@ namespace Misaki.GraphView.Editor
|
|||||||
{
|
{
|
||||||
public struct SearchContextElement
|
public struct SearchContextElement
|
||||||
{
|
{
|
||||||
public object Target { get; }
|
public object Target
|
||||||
public string Title { get; }
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
public SearchContextElement(object target, string title)
|
public SearchContextElement(object target, string title)
|
||||||
{
|
{
|
||||||
@@ -159,6 +165,7 @@ namespace Misaki.GraphView.Editor
|
|||||||
|
|
||||||
node.position = new Rect(graphMousePosition, Vector2.zero);
|
node.position = new Rect(graphMousePosition, Vector2.zero);
|
||||||
_owner.AddNode(node);
|
_owner.AddNode(node);
|
||||||
|
_owner.GraphViewConfig.serializedObject.Update();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ namespace Misaki.GraphView.Editor
|
|||||||
AddRelayNode(relayNode, edge);
|
AddRelayNode(relayNode, edge);
|
||||||
}, DropdownMenuAction.AlwaysEnabled);
|
}, DropdownMenuAction.AlwaysEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selection.Count > 0)
|
||||||
|
{
|
||||||
|
evt.menu.AppendAction("Group Selected Nodes", e =>
|
||||||
|
{
|
||||||
|
|
||||||
|
}, DropdownMenuAction.AlwaysEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,10 +60,13 @@ namespace Misaki.GraphView.Editor
|
|||||||
input.Disconnect(edge);
|
input.Disconnect(edge);
|
||||||
output.Disconnect(edge);
|
output.Disconnect(edge);
|
||||||
|
|
||||||
//_dataNode.BindSlot(inputSlot);
|
_dataNode.BindSlot(inputSlot);
|
||||||
//_dataNode.BindSlot(outputSlot);
|
_dataNode.BindSlot(outputSlot);
|
||||||
|
|
||||||
|
var outputProxySlot = (ProxySlot)_dataNode.GetSlot(0, SlotDirection.Output);
|
||||||
|
inputSlot.Link(outputProxySlot.MasterSlot, out _);
|
||||||
|
inputConnection = new(inputSlot.SlotData, outputProxySlot.SlotData);
|
||||||
|
|
||||||
inputSlot.Link(_dataNode.GetSlot(0, SlotDirection.Output), out inputConnection);
|
|
||||||
_dataNode.GetSlot(0, SlotDirection.Input).Link(outputSlot, out outputConnection);
|
_dataNode.GetSlot(0, SlotDirection.Input).Link(outputSlot, out outputConnection);
|
||||||
|
|
||||||
inputEdge = output.ConnectTo(_inputPort);
|
inputEdge = output.ConnectTo(_inputPort);
|
||||||
@@ -78,17 +81,24 @@ namespace Misaki.GraphView.Editor
|
|||||||
newConnections = new List<SlotConnection>();
|
newConnections = new List<SlotConnection>();
|
||||||
newEdges = new List<Edge>();
|
newEdges = new List<Edge>();
|
||||||
|
|
||||||
if (_inputPort.userData is not Slot inputSlot || _outputPort.userData is not Slot outputSlot)
|
if (_inputPort.userData is not ProxySlot inputSlot || _outputPort.userData is not ProxySlot outputSlot)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkedOutputPort = _inputPort.connections.FirstOrDefault().output;
|
var linkedOutputPort = _inputPort.connections.FirstOrDefault()?.output;
|
||||||
|
|
||||||
|
if (linkedOutputPort == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
inputSlot.MasterSlot.Unlink(outputSlot.MasterSlot);
|
||||||
|
|
||||||
foreach (var edge in _outputPort.connections.ToList())
|
foreach (var edge in _outputPort.connections.ToList())
|
||||||
{
|
{
|
||||||
var linkedInputPort = edge.input;
|
var linkedInputPort = edge.input;
|
||||||
if (linkedOutputPort.userData is Slot linkedOutputSlot && linkedInputPort.userData is Slot linkedInputSlot)
|
if (linkedOutputPort.userData is ISlot linkedOutputSlot && linkedInputPort.userData is ISlot linkedInputSlot)
|
||||||
{
|
{
|
||||||
linkedOutputSlot.Link(linkedInputSlot, out var inputConnection);
|
linkedOutputSlot.Link(linkedInputSlot, out var inputConnection);
|
||||||
newConnections.Add(inputConnection);
|
newConnections.Add(inputConnection);
|
||||||
|
|||||||
@@ -1,29 +1,45 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Misaki.GraphView
|
namespace Misaki.GraphView
|
||||||
{
|
{
|
||||||
public interface ISlot
|
public interface ISlot
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The slot data.
|
||||||
|
/// </summary>
|
||||||
public SlotData SlotData
|
public SlotData SlotData
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The linked slot datas.
|
||||||
|
/// </summary>
|
||||||
public List<SlotData> LinkedSlotDatas
|
public List<SlotData> LinkedSlotDatas
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is the slot linked with another slot.
|
||||||
|
/// </summary>
|
||||||
public bool IsLinked
|
public bool IsLinked
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The owner of the slot.
|
||||||
|
/// </summary>
|
||||||
public DataNode Owner
|
public DataNode Owner
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data buffer of the slot.
|
||||||
|
/// </summary>
|
||||||
public object Data
|
public object Data
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -43,6 +59,18 @@ namespace Misaki.GraphView
|
|||||||
/// <param name="other"> <see cref="ISlot"/> The slot need to be unlinked </param>
|
/// <param name="other"> <see cref="ISlot"/> The slot need to be unlinked </param>
|
||||||
public void Unlink(ISlot other);
|
public void Unlink(ISlot other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pull data from the linked slot to current slot.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="OnPullData">The action to execute when pulling data.</param>
|
||||||
|
public void PullData(Action<ISlot> OnPullData);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Push data from the current slot to linked slot.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="OnPushData">The action to execute when pushing data.</param>
|
||||||
|
public void PushData(Action<ISlot> OnPushData);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send data to the slot.
|
/// Send data to the slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
{
|
{
|
||||||
public interface IExecutable
|
public interface IExecutable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the node is executed.
|
||||||
|
/// </summary>
|
||||||
public bool IsExecuted
|
public bool IsExecuted
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -2,18 +2,6 @@
|
|||||||
{
|
{
|
||||||
public interface ISlotContainer
|
public interface ISlotContainer
|
||||||
{
|
{
|
||||||
///// <summary>
|
|
||||||
///// Add the slot to the container.
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="slot"> <see cref="ISlot"/> The slot want to add </param>
|
|
||||||
//public void AddSlot(ISlot slot);
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Remove the slot from the container.
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="slot"> <see cref="ISlot"/> The slot want to remove </param>
|
|
||||||
//public void RemoveSlot(ISlot slot);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the slot by the index and direction.
|
/// Get the slot by the index and direction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -34,87 +34,6 @@ namespace Misaki.GraphView
|
|||||||
return Type.GetType(slotData.valueType);
|
return Type.GetType(slotData.valueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Pull data from the slot to property and execute the provided action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="slot">The slot to pull data from.</param>
|
|
||||||
/// <param name="OnPullData">The action to execute when pulling data.</param>
|
|
||||||
public static void PullData(this ISlot slot, Action<ISlot> OnPullData)
|
|
||||||
{
|
|
||||||
if (slot.SlotData.direction == SlotDirection.Output)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var slotData in slot.LinkedSlotDatas)
|
|
||||||
{
|
|
||||||
var node = slot.Owner.GraphObject.GetNode(slotData.nodeID);
|
|
||||||
if (node is not IExecutable executable)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!executable.IsExecuted)
|
|
||||||
{
|
|
||||||
executable.Execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OnPullData?.Invoke(slot);
|
|
||||||
|
|
||||||
var property = slot.Owner.GetType().GetField(slot.SlotData.slotName, ConstResource.NODE_FIELD_BINDING_FLAGS);
|
|
||||||
if (slot.IsLinked && property != null)
|
|
||||||
{
|
|
||||||
property?.SetValue(slot.Owner, slot.Data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Push data to the slot and execute the provided action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="slot">The slot to push data to.</param>
|
|
||||||
/// <param name="OnPushData">The action to execute when pushing data.</param>
|
|
||||||
public static void PushData(this ISlot slot, Action<ISlot> OnPushData)
|
|
||||||
{
|
|
||||||
if (slot.SlotData.direction == SlotDirection.Input)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var property = slot.Owner.GetType().GetField(slot.SlotData.slotName, ConstResource.NODE_FIELD_BINDING_FLAGS);
|
|
||||||
if (property != null)
|
|
||||||
{
|
|
||||||
slot.ReceiveData(property.GetValue(slot.Owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
OnPushData?.Invoke(slot);
|
|
||||||
|
|
||||||
foreach (var connectedSlotData in slot.LinkedSlotDatas)
|
|
||||||
{
|
|
||||||
var node = slot.Owner.GraphObject.GetNode(connectedSlotData.nodeID);
|
|
||||||
if (node is not ISlotContainer slotContainer)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var connectedSlot = slotContainer.GetSlot(connectedSlotData.slotIndex, connectedSlotData.direction);
|
|
||||||
|
|
||||||
if (connectedSlotData.GetValueType() == slot.SlotData.GetValueType() || slot.SlotData.GetValueType() == typeof(object) || connectedSlotData.GetValueType() == typeof(object))
|
|
||||||
{
|
|
||||||
connectedSlot.ReceiveData(slot.Data);
|
|
||||||
}
|
|
||||||
else if (slot.Owner.GraphObject.ValueConverterManager != null && slot.Owner.GraphObject.ValueConverterManager.TryConvert(slot.SlotData.GetValueType(),
|
|
||||||
connectedSlotData.GetValueType(), slot.Data, out var data))
|
|
||||||
{
|
|
||||||
connectedSlot.ReceiveData(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slot.Owner.GraphObject.Logger?.LogError(slot.Owner, $"Failed to convert value from {slot.SlotData.valueType} to {connectedSlotData.valueType}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pull data from a collection of slots and execute the provided action.
|
/// Pull data from a collection of slots and execute the provided action.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace Misaki.GraphView
|
|||||||
private List<SlotConnection> _connections = new();
|
private List<SlotConnection> _connections = new();
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
private List<ExposedProperty> _exposedProperties = new();
|
private List<ExposedProperty> _exposedProperties = new();
|
||||||
|
[SerializeField]
|
||||||
|
private List<NodeGroupData> nodeGroupDatas = new();
|
||||||
|
|
||||||
private readonly Dictionary<string, DataNode> _nodeMap = new();
|
private readonly Dictionary<string, DataNode> _nodeMap = new();
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ namespace Misaki.GraphView
|
|||||||
public ReadOnlyCollection<StickyNoteData> StickyNotes => _stickyNotes.AsReadOnly();
|
public ReadOnlyCollection<StickyNoteData> StickyNotes => _stickyNotes.AsReadOnly();
|
||||||
public ReadOnlyCollection<SlotConnection> Connections => _connections.AsReadOnly();
|
public ReadOnlyCollection<SlotConnection> Connections => _connections.AsReadOnly();
|
||||||
public ReadOnlyCollection<ExposedProperty> ExposedProperties => _exposedProperties.AsReadOnly();
|
public ReadOnlyCollection<ExposedProperty> ExposedProperties => _exposedProperties.AsReadOnly();
|
||||||
|
public ReadOnlyCollection<NodeGroupData> NodeGroupDatas => nodeGroupDatas.AsReadOnly();
|
||||||
|
|
||||||
public Vector3 graphPosition;
|
public Vector3 graphPosition;
|
||||||
public Vector3 graphScale = Vector3.one;
|
public Vector3 graphScale = Vector3.one;
|
||||||
|
|||||||
20
Runtime/Models/Nodes/NodeGroupData.cs
Normal file
20
Runtime/Models/Nodes/NodeGroupData.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Misaki.GraphView
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public struct NodeGroupData
|
||||||
|
{
|
||||||
|
public string id;
|
||||||
|
public string name;
|
||||||
|
public List<string> nodeIds;
|
||||||
|
|
||||||
|
public NodeGroupData(string groupName)
|
||||||
|
{
|
||||||
|
id = Guid.NewGuid().ToString();
|
||||||
|
name = groupName;
|
||||||
|
nodeIds = new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Runtime/Models/Nodes/NodeGroupData.cs.meta
Normal file
2
Runtime/Models/Nodes/NodeGroupData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fcd834a0bef681248b79c1cc4648c27e
|
||||||
@@ -4,16 +4,12 @@ using UnityEngine;
|
|||||||
namespace Misaki.GraphView
|
namespace Misaki.GraphView
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RelayNode : DataNode, ISlotContainer, IExecutable
|
public class RelayNode : DataNode, ISlotContainer
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Slot _inputSlot;
|
private ProxySlot _inputSlot;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Slot _outputSlot;
|
private ProxySlot _outputSlot;
|
||||||
|
|
||||||
private bool _isExecuted;
|
|
||||||
|
|
||||||
public bool IsExecuted => _isExecuted;
|
|
||||||
|
|
||||||
public string portValueType;
|
public string portValueType;
|
||||||
|
|
||||||
@@ -21,7 +17,7 @@ namespace Misaki.GraphView
|
|||||||
{
|
{
|
||||||
base.Initialize(graph);
|
base.Initialize(graph);
|
||||||
|
|
||||||
_inputSlot = new Slot(this, new SlotData
|
_inputSlot = new(this, new SlotData
|
||||||
{
|
{
|
||||||
slotName = "Input",
|
slotName = "Input",
|
||||||
nodeID = Id,
|
nodeID = Id,
|
||||||
@@ -29,8 +25,7 @@ namespace Misaki.GraphView
|
|||||||
direction = SlotDirection.Input,
|
direction = SlotDirection.Input,
|
||||||
valueType = typeof(object).FullName
|
valueType = typeof(object).FullName
|
||||||
});
|
});
|
||||||
|
_outputSlot = new(this, new SlotData
|
||||||
_outputSlot = new Slot(this, new SlotData
|
|
||||||
{
|
{
|
||||||
slotName = "Output",
|
slotName = "Output",
|
||||||
nodeID = Id,
|
nodeID = Id,
|
||||||
@@ -42,22 +37,39 @@ namespace Misaki.GraphView
|
|||||||
portValueType = typeof(object).FullName;
|
portValueType = typeof(object).FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// Bind the slot to the relay node.
|
/// Bind the slot to the relay node.
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="slot"> <see cref="ISlot"/> The slot want to bind to current relay node </param>
|
/// <param name="slot"> <see cref="ISlot"/> The slot want to bind to current relay node </param>
|
||||||
//public void BindSlot(ISlot slot)
|
public void BindSlot(ISlot slot)
|
||||||
//{
|
{
|
||||||
// switch (slot.SlotData.direction)
|
switch (slot.SlotData.direction)
|
||||||
// {
|
{
|
||||||
// case SlotDirection.Input:
|
case SlotDirection.Input:
|
||||||
// _inputSlot.Bind(slot);
|
_inputSlot.Bind(slot);
|
||||||
// break;
|
break;
|
||||||
// case SlotDirection.Output:
|
case SlotDirection.Output:
|
||||||
// _outputSlot.Bind(slot);
|
_outputSlot.Bind(slot);
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unbind the slot from the relay node.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction"> The direction of the slot </param>
|
||||||
|
public void UnbindSlot(SlotDirection direction)
|
||||||
|
{
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case SlotDirection.Input:
|
||||||
|
_inputSlot.Unbind();
|
||||||
|
break;
|
||||||
|
case SlotDirection.Output:
|
||||||
|
_outputSlot.Unbind();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ISlot GetSlot(int index, SlotDirection direction)
|
public ISlot GetSlot(int index, SlotDirection direction)
|
||||||
{
|
{
|
||||||
@@ -75,23 +87,12 @@ namespace Misaki.GraphView
|
|||||||
_outputSlot.UnlinkAll();
|
_outputSlot.UnlinkAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
if (_isExecuted)
|
base.Dispose();
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_inputSlot.PullData(null);
|
_inputSlot.Unbind();
|
||||||
_outputSlot.ReceiveData(_inputSlot.Data);
|
_outputSlot.Unbind();
|
||||||
_outputSlot.PushData(null);
|
|
||||||
|
|
||||||
_isExecuted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearExecutionFlag()
|
|
||||||
{
|
|
||||||
_isExecuted = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,37 +8,76 @@ namespace Misaki.GraphView
|
|||||||
public class ProxySlot : ISlot
|
public class ProxySlot : ISlot
|
||||||
{
|
{
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
private ISlot _slot;
|
private ISlot _masterSlot;
|
||||||
|
|
||||||
public SlotData SlotData => _slot == null ? default : _slot.SlotData;
|
[SerializeField]
|
||||||
public List<SlotData> LinkedSlotDatas => _slot?.LinkedSlotDatas;
|
private SlotData _slotData;
|
||||||
public bool IsLinked => LinkedSlotDatas?.Count > 0;
|
[SerializeField]
|
||||||
public DataNode Owner => _slot?.Owner;
|
private List<SlotData> _linkedSlotDatas = new();
|
||||||
public object Data => _slot?.Data;
|
[SerializeReference]
|
||||||
|
private DataNode _owner;
|
||||||
|
|
||||||
|
public SlotData SlotData => _slotData;
|
||||||
|
public List<SlotData> LinkedSlotDatas => _linkedSlotDatas;
|
||||||
|
public bool IsLinked => _linkedSlotDatas.Count > 0;
|
||||||
|
public DataNode Owner => _owner;
|
||||||
|
|
||||||
|
public ISlot MasterSlot => _masterSlot;
|
||||||
|
public object Data => _masterSlot?.Data;
|
||||||
|
|
||||||
|
public ProxySlot(DataNode owner, SlotData slotData)
|
||||||
|
{
|
||||||
|
_owner = owner;
|
||||||
|
_slotData = slotData;
|
||||||
|
}
|
||||||
|
|
||||||
public void Bind(ISlot slot)
|
public void Bind(ISlot slot)
|
||||||
{
|
{
|
||||||
_slot = slot;
|
_masterSlot = slot;
|
||||||
|
|
||||||
|
_slotData.direction = slot.SlotData.direction;
|
||||||
|
_slotData.valueType = slot.SlotData.valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unbind()
|
||||||
|
{
|
||||||
|
_masterSlot = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Link(ISlot other, out SlotConnection connection)
|
public bool Link(ISlot other, out SlotConnection connection)
|
||||||
{
|
{
|
||||||
if (_slot == null)
|
connection = new(_slotData, other.SlotData);
|
||||||
|
|
||||||
|
if (other.SlotData.direction == _slotData.direction ||
|
||||||
|
_linkedSlotDatas.Contains(other.SlotData) ||
|
||||||
|
_masterSlot == null)
|
||||||
{
|
{
|
||||||
connection = default;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _slot.Link(other, out connection);
|
_linkedSlotDatas.Add(other.SlotData);
|
||||||
|
return _masterSlot.Link(other, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unlink(ISlot other)
|
public void Unlink(ISlot other)
|
||||||
{
|
{
|
||||||
_slot?.Unlink(other);
|
_linkedSlotDatas.Remove(other.SlotData);
|
||||||
|
_masterSlot?.Unlink(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PullData(Action<ISlot> OnPullData)
|
||||||
|
{
|
||||||
|
_masterSlot.PullData(OnPullData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PushData(Action<ISlot> OnPushData)
|
||||||
|
{
|
||||||
|
_masterSlot.PushData(OnPushData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReceiveData(object data)
|
public void ReceiveData(object data)
|
||||||
{
|
{
|
||||||
_slot?.ReceiveData(data);
|
_masterSlot?.ReceiveData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,56 +4,21 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace Misaki.GraphView
|
namespace Misaki.GraphView
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public struct SlotData : IEquatable<SlotData>
|
|
||||||
{
|
|
||||||
public string slotName;
|
|
||||||
public string nodeID;
|
|
||||||
public int slotIndex;
|
|
||||||
public SlotDirection direction;
|
|
||||||
public string valueType;
|
|
||||||
|
|
||||||
public bool Equals(SlotData other)
|
|
||||||
{
|
|
||||||
return slotName == other.slotName && nodeID == other.nodeID && slotIndex == other.slotIndex && direction == other.direction && valueType == other.valueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is SlotData other && Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(slotName, nodeID, slotIndex, direction, valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(SlotData left, SlotData right)
|
|
||||||
{
|
|
||||||
return left.Equals(right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(SlotData left, SlotData right)
|
|
||||||
{
|
|
||||||
return !left.Equals(right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Slot : ISlot
|
public class Slot : ISlot
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private SlotData _slotData;
|
private SlotData _slotData;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<SlotData> _linkedSlotData = new();
|
private List<SlotData> _linkedSlotDatas = new();
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
private DataNode _owner;
|
private DataNode _owner;
|
||||||
|
|
||||||
private object _data;
|
private object _data;
|
||||||
|
|
||||||
public SlotData SlotData => _slotData;
|
public SlotData SlotData => _slotData;
|
||||||
public List<SlotData> LinkedSlotDatas => _linkedSlotData;
|
public List<SlotData> LinkedSlotDatas => _linkedSlotDatas;
|
||||||
public bool IsLinked => _linkedSlotData.Count > 0;
|
public bool IsLinked => _linkedSlotDatas.Count > 0;
|
||||||
public DataNode Owner => _owner;
|
public DataNode Owner => _owner;
|
||||||
public object Data => _data;
|
public object Data => _data;
|
||||||
|
|
||||||
@@ -66,31 +31,86 @@ namespace Misaki.GraphView
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool Link(ISlot other, out SlotConnection connection)
|
public bool Link(ISlot other, out SlotConnection connection)
|
||||||
{
|
{
|
||||||
connection = default;
|
|
||||||
if (other.SlotData.direction == _slotData.direction)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_linkedSlotData.Contains(other.SlotData))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_linkedSlotData.Add(other.SlotData);
|
|
||||||
other.LinkedSlotDatas.Add(_slotData);
|
|
||||||
connection = new(_slotData, other.SlotData);
|
connection = new(_slotData, other.SlotData);
|
||||||
|
|
||||||
|
if (other.SlotData.direction == _slotData.direction ||
|
||||||
|
_linkedSlotDatas.Contains(other.SlotData))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_linkedSlotDatas.Add(other.SlotData);
|
||||||
|
other.LinkedSlotDatas.Add(_slotData);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Unlink(ISlot other)
|
public void Unlink(ISlot other)
|
||||||
{
|
{
|
||||||
_linkedSlotData.Remove(other.SlotData);
|
_linkedSlotDatas.Remove(other.SlotData);
|
||||||
other.LinkedSlotDatas.Remove(_slotData);
|
other.LinkedSlotDatas.Remove(_slotData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void PullData(Action<ISlot> OnPullData)
|
||||||
|
{
|
||||||
|
if (_slotData.direction == SlotDirection.Output)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPullData?.Invoke(this);
|
||||||
|
|
||||||
|
var property = _owner.GetType().GetField(_slotData.slotName, ConstResource.NODE_FIELD_BINDING_FLAGS);
|
||||||
|
if (IsLinked && property != null)
|
||||||
|
{
|
||||||
|
property?.SetValue(_owner, _data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PushData(Action<ISlot> OnPushData)
|
||||||
|
{
|
||||||
|
if (_slotData.direction == SlotDirection.Input)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var property = _owner.GetType().GetField(_slotData.slotName, ConstResource.NODE_FIELD_BINDING_FLAGS);
|
||||||
|
if (property != null)
|
||||||
|
{
|
||||||
|
ReceiveData(property.GetValue(_owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
OnPushData?.Invoke(this);
|
||||||
|
|
||||||
|
foreach (var connectedSlotData in _linkedSlotDatas)
|
||||||
|
{
|
||||||
|
var node = _owner.GraphObject.GetNode(connectedSlotData.nodeID);
|
||||||
|
if (node is not ISlotContainer slotContainer)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var connectedSlot = slotContainer.GetSlot(connectedSlotData.slotIndex, connectedSlotData.direction);
|
||||||
|
|
||||||
|
if (connectedSlotData.GetValueType() == _slotData.GetValueType() || _slotData.GetValueType() == typeof(object) || connectedSlotData.GetValueType() == typeof(object))
|
||||||
|
{
|
||||||
|
connectedSlot.ReceiveData(_data);
|
||||||
|
}
|
||||||
|
else if (_owner.GraphObject.ValueConverterManager != null && _owner.GraphObject.ValueConverterManager.TryConvert(_slotData.GetValueType(),
|
||||||
|
connectedSlotData.GetValueType(), _data, out var data))
|
||||||
|
{
|
||||||
|
connectedSlot.ReceiveData(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_owner.GraphObject.Logger?.LogError(_owner, $"Failed to convert value from {_slotData.valueType} to {connectedSlotData.valueType}");
|
||||||
|
_owner.GraphObject.GraphProcessor.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void ReceiveData(object data)
|
public void ReceiveData(object data)
|
||||||
{
|
{
|
||||||
|
|||||||
39
Runtime/Models/Slots/SlotData.cs
Normal file
39
Runtime/Models/Slots/SlotData.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Misaki.GraphView
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public struct SlotData : IEquatable<SlotData>
|
||||||
|
{
|
||||||
|
public string slotName;
|
||||||
|
public string nodeID;
|
||||||
|
public int slotIndex;
|
||||||
|
public SlotDirection direction;
|
||||||
|
public string valueType;
|
||||||
|
|
||||||
|
public bool Equals(SlotData other)
|
||||||
|
{
|
||||||
|
return slotName == other.slotName && nodeID == other.nodeID && slotIndex == other.slotIndex && direction == other.direction && valueType == other.valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return obj is SlotData other && Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(slotName, nodeID, slotIndex, direction, valueType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(SlotData left, SlotData right)
|
||||||
|
{
|
||||||
|
return left.Equals(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SlotData left, SlotData right)
|
||||||
|
{
|
||||||
|
return !left.Equals(right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Runtime/Models/Slots/SlotData.cs.meta
Normal file
2
Runtime/Models/Slots/SlotData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0895a7c121619ff4986f686264e1afa2
|
||||||
@@ -13,170 +13,169 @@ MonoBehaviour:
|
|||||||
m_Name: GraphAsset
|
m_Name: GraphAsset
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_nodes:
|
_nodes:
|
||||||
- rid: 299037664908935259
|
- rid: 299037684865171562
|
||||||
- rid: 299037664908935263
|
- rid: 299037684865171566
|
||||||
- rid: 299037666265792792
|
- rid: 299037684865171575
|
||||||
_stickyNotes: []
|
_stickyNotes: []
|
||||||
_connections:
|
_connections:
|
||||||
- _inputSlotData:
|
- _inputSlotData:
|
||||||
slotName: _input
|
slotName: _input
|
||||||
nodeID: beccbada-5a7c-4804-a24d-d88417579758
|
nodeID: 79330303-2194-47fc-a59f-509ea2101a57
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_outputSlotData:
|
_outputSlotData:
|
||||||
slotName: Output
|
slotName: Output
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: 067bd91d-b0d8-4195-afd2-abfaee6d3097
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Object
|
valueType: System.Single
|
||||||
- _inputSlotData:
|
- _inputSlotData:
|
||||||
slotName: Input
|
slotName: Input
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: 067bd91d-b0d8-4195-afd2-abfaee6d3097
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Object
|
valueType: System.Single
|
||||||
_outputSlotData:
|
_outputSlotData:
|
||||||
slotName: _result
|
slotName: _result
|
||||||
nodeID: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_exposedProperties: []
|
_exposedProperties: []
|
||||||
graphPosition: {x: 82.666664, y: 8.666667, z: 0}
|
graphPosition: {x: -122.666664, y: 15.333333, z: 0}
|
||||||
graphScale: {x: 1, y: 1, z: 1}
|
graphScale: {x: 1, y: 1, z: 1}
|
||||||
references:
|
references:
|
||||||
version: 2
|
version: 2
|
||||||
RefIds:
|
RefIds:
|
||||||
- rid: 299037664908935259
|
- rid: 299037684865171562
|
||||||
type: {class: Add, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
|
type: {class: Add, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
|
||||||
data:
|
data:
|
||||||
graphObject: {fileID: 11400000}
|
graphObject: {fileID: 11400000}
|
||||||
id: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
id: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
position:
|
position:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
x: 502.66666
|
x: 438.66666
|
||||||
y: 447.3333
|
y: 475.99997
|
||||||
width: 116.66669
|
width: 117.33331
|
||||||
height: 102.66666
|
height: 102.66669
|
||||||
_inputs:
|
_inputs:
|
||||||
- rid: 299037664908935260
|
- rid: 299037684865171563
|
||||||
- rid: 299037664908935261
|
- rid: 299037684865171564
|
||||||
_outputs:
|
_outputs:
|
||||||
- rid: 299037664908935262
|
- rid: 299037684865171565
|
||||||
a: 1
|
a: 1
|
||||||
b: 3
|
b: 1
|
||||||
- rid: 299037664908935260
|
- rid: 299037684865171563
|
||||||
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
||||||
data:
|
data:
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: a
|
slotName: a
|
||||||
nodeID: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_linkedSlotData: []
|
_linkedSlotDatas: []
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037664908935259
|
rid: 299037684865171562
|
||||||
- rid: 299037664908935261
|
- rid: 299037684865171564
|
||||||
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
||||||
data:
|
data:
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: b
|
slotName: b
|
||||||
nodeID: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 1
|
slotIndex: 1
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_linkedSlotData: []
|
_linkedSlotDatas: []
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037664908935259
|
rid: 299037684865171562
|
||||||
- rid: 299037664908935262
|
- rid: 299037684865171565
|
||||||
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
||||||
data:
|
data:
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: _result
|
slotName: _result
|
||||||
nodeID: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_linkedSlotData:
|
_linkedSlotDatas:
|
||||||
- slotName: Input
|
- slotName: _input
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: 79330303-2194-47fc-a59f-509ea2101a57
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Object
|
valueType: System.Single
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037664908935259
|
rid: 299037684865171562
|
||||||
- rid: 299037664908935263
|
- rid: 299037684865171566
|
||||||
type: {class: Output, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
|
type: {class: Output, ns: Misaki.GraphView.Sample, asm: GraphView.Sample}
|
||||||
data:
|
data:
|
||||||
graphObject: {fileID: 11400000}
|
graphObject: {fileID: 11400000}
|
||||||
id: beccbada-5a7c-4804-a24d-d88417579758
|
id: 79330303-2194-47fc-a59f-509ea2101a57
|
||||||
position:
|
position:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
x: 791.3334
|
x: 1124.6666
|
||||||
y: 447.3333
|
y: 475.99997
|
||||||
width: 124.666626
|
width: 124.666626
|
||||||
height: 78.66666
|
height: 78.66669
|
||||||
_inputs:
|
_inputs:
|
||||||
- rid: 299037664908935264
|
- rid: 299037684865171567
|
||||||
_outputs: []
|
_outputs: []
|
||||||
- rid: 299037664908935264
|
- rid: 299037684865171567
|
||||||
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
type: {class: Slot, ns: Misaki.GraphView, asm: GraphView}
|
||||||
data:
|
data:
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: _input
|
slotName: _input
|
||||||
nodeID: beccbada-5a7c-4804-a24d-d88417579758
|
nodeID: 79330303-2194-47fc-a59f-509ea2101a57
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_linkedSlotData:
|
_linkedSlotDatas:
|
||||||
- slotName: Output
|
- slotName: _result
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Object
|
valueType: System.Single
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037664908935263
|
rid: 299037684865171566
|
||||||
- rid: 299037666265792792
|
- rid: 299037684865171575
|
||||||
type: {class: RelayNode, ns: Misaki.GraphView, asm: GraphView}
|
type: {class: RelayNode, ns: Misaki.GraphView, asm: GraphView}
|
||||||
data:
|
data:
|
||||||
graphObject: {fileID: 11400000}
|
graphObject: {fileID: 11400000}
|
||||||
id: 37104284-ca2e-4e27-b71b-ab692270407a
|
id: 067bd91d-b0d8-4195-afd2-abfaee6d3097
|
||||||
position:
|
position:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
x: 660.6667
|
x: 788.6667
|
||||||
y: 492.66666
|
y: 521.3334
|
||||||
width: 74.66669
|
width: 74.66669
|
||||||
height: 33.333313
|
height: 33.333313
|
||||||
_inputSlot:
|
_inputSlot:
|
||||||
|
_masterSlot:
|
||||||
|
rid: 299037684865171567
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: Input
|
slotName: Input
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: 067bd91d-b0d8-4195-afd2-abfaee6d3097
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 0
|
direction: 0
|
||||||
valueType: System.Object
|
valueType: System.Single
|
||||||
_linkedSlotData:
|
_linkedSlotDatas:
|
||||||
- slotName: _result
|
- slotName: _result
|
||||||
nodeID: 9c9e190e-4658-4c0f-8c6d-93e99cc6326b
|
nodeID: fb4f0b75-0e99-4374-8856-cf9d9dee5c4e
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037666265792792
|
rid: 299037684865171575
|
||||||
_outputSlot:
|
_outputSlot:
|
||||||
|
_masterSlot:
|
||||||
|
rid: 299037684865171565
|
||||||
_slotData:
|
_slotData:
|
||||||
slotName: Output
|
slotName: Output
|
||||||
nodeID: 37104284-ca2e-4e27-b71b-ab692270407a
|
nodeID: 067bd91d-b0d8-4195-afd2-abfaee6d3097
|
||||||
slotIndex: 0
|
slotIndex: 0
|
||||||
direction: 1
|
direction: 1
|
||||||
valueType: System.Object
|
|
||||||
_linkedSlotData:
|
|
||||||
- slotName: _input
|
|
||||||
nodeID: beccbada-5a7c-4804-a24d-d88417579758
|
|
||||||
slotIndex: 0
|
|
||||||
direction: 0
|
|
||||||
valueType: System.Single
|
valueType: System.Single
|
||||||
|
_linkedSlotDatas: []
|
||||||
_owner:
|
_owner:
|
||||||
rid: 299037666265792792
|
rid: 299037684865171575
|
||||||
portValueType: System.Single
|
portValueType: System.Single
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Misaki.GraphView.Editor;
|
|||||||
namespace Misaki.GraphView.Sample
|
namespace Misaki.GraphView.Sample
|
||||||
{
|
{
|
||||||
[NodeInfo("Add", "Math")]
|
[NodeInfo("Add", "Math")]
|
||||||
public class Add : ExecutableNode
|
public class Add : BackTraceExecutableNode
|
||||||
{
|
{
|
||||||
[NodeInput]
|
[NodeInput]
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
|||||||
8
Sample/Runtime/Models/Nodes/BaseClasses.meta
Normal file
8
Sample/Runtime/Models/Nodes/BaseClasses.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b5cf6534e577abb45a6f0a178aba73eb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Misaki.GraphView.Sample
|
||||||
|
{
|
||||||
|
public abstract class BackTraceExecutableNode : ExecutableNode
|
||||||
|
{
|
||||||
|
protected override void OnPullData(ISlot input)
|
||||||
|
{
|
||||||
|
if (input.LinkedSlotDatas.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var outputNode = GraphObject.GetNode(input.LinkedSlotDatas[0].nodeID);
|
||||||
|
if (outputNode is IExecutable executable)
|
||||||
|
{
|
||||||
|
executable.Execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45807fa2f84655b4783b18aee34a21c9
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Misaki.GraphView.Sample
|
namespace Misaki.GraphView.Sample
|
||||||
{
|
{
|
||||||
[NodeInfo("Output Node", "Output")]
|
[NodeInfo("Output Node", "Output")]
|
||||||
public class Output : ExecutableNode
|
public class Output : BackTraceExecutableNode
|
||||||
{
|
{
|
||||||
[NodeInput]
|
[NodeInput]
|
||||||
private float _input;
|
private float _input;
|
||||||
|
|||||||
Reference in New Issue
Block a user