浏览代码

Add DepthFirstCollectNodesFromNodeSlotList (allows a list of input slot instead one)

/main
Paul Demeulenaere 8 年前
当前提交
94144e69
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 13
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs

13
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/NodeUtils.cs


public static void DepthFirstCollectNodesFromNode(List<INode> nodeList, INode node, int? slotId = null, IncludeSelf includeSelf = IncludeSelf.Include)
{
DepthFirstCollectNodesFromNodeSlotList(nodeList, node, slotId.HasValue ? new List<int>() { slotId.Value } : null, includeSelf);
}
public static void DepthFirstCollectNodesFromNodeSlotList(List<INode> nodeList, INode node, List<int> slotId = null, IncludeSelf includeSelf = IncludeSelf.Include)
{
// no where to start
if (node == null)
return;

return;
// if we have a slot passed in but can not find it on the node abort
if (slotId.HasValue && node.GetInputSlots<ISlot>().All(x => x.id != slotId.Value))
if (slotId != null && node.GetInputSlots<ISlot>().All(x => !slotId.Contains(x.id)))
if (slotId.HasValue)
validSlots.Add(slotId.Value);
if (slotId != null)
slotId.ForEach(x => validSlots.Add(x));
else
validSlots.AddRange(node.GetInputSlots<ISlot>().Select(x => x.id));

{
var outputNode = node.owner.GetNodeFromGuid(edge.outputSlot.nodeGuid);
DepthFirstCollectNodesFromNode(nodeList, outputNode);
DepthFirstCollectNodesFromNodeSlotList(nodeList, outputNode);
}
}

正在加载...
取消
保存