浏览代码

rename anchor > port

/main
Tim Cooper 7 年前
当前提交
9e5cc1af
共有 3 个文件被更改,包括 13 次插入13 次删除
  1. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
  3. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


var sourceNodeView = m_GraphView.nodes.ToList().OfType<MaterialNodeView>().FirstOrDefault(x => x.node == sourceNode);
if (sourceNodeView != null)
{
var sourceAnchor = sourceNodeView.outputContainer.Children().OfType<NodeAnchor>().FirstOrDefault(x => x.userData is ISlot && (x.userData as ISlot).Equals(sourceSlot));
var sourceAnchor = sourceNodeView.outputContainer.Children().OfType<Port>().FirstOrDefault(x => x.userData is ISlot && (x.userData as ISlot).Equals(sourceSlot));
var targetAnchor = targetNodeView.inputContainer.Children().OfType<NodeAnchor>().FirstOrDefault(x => x.userData is ISlot && (x.userData as ISlot).Equals(targetSlot));
var targetAnchor = targetNodeView.inputContainer.Children().OfType<Port>().FirstOrDefault(x => x.userData is ISlot && (x.userData as ISlot).Equals(targetSlot));
var edgeView = new GradientEdge
{

edgeView.output.Connect(edgeView);
edgeView.input.Connect(edgeView);
m_GraphView.AddElement(edgeView);
sourceNodeView.RefreshAnchors();
targetNodeView.RefreshAnchors();
sourceNodeView.RefreshPorts();
targetNodeView.RefreshPorts();
sourceNodeView.UpdatePortInputTypes();
targetNodeView.UpdatePortInputTypes();

{
var nodeView = nodeStack.Pop();
nodeView.UpdatePortInputTypes();
foreach (var anchorView in nodeView.outputContainer.Children().OfType<NodeAnchor>())
foreach (var anchorView in nodeView.outputContainer.Children().OfType<Port>())
{
var sourceSlot = (MaterialSlot)anchorView.userData;
foreach (var edgeView in anchorView.connections.OfType<GradientEdge>())

}
}
}
foreach (var anchorView in nodeView.inputContainer.Children().OfType<NodeAnchor>())
foreach (var anchorView in nodeView.inputContainer.Children().OfType<Port>())
{
var targetSlot = (MaterialSlot)anchorView.userData;
if (targetSlot.valueType != SlotValueType.Dynamic)

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


{
public AbstractMaterialGraph graph { get; private set; }
public override List<NodeAnchor> GetCompatibleAnchors(NodeAnchor startAnchor, NodeAdapter nodeAdapter)
public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter nodeAdapter)
var compatibleAnchors = new List<NodeAnchor>();
var compatibleAnchors = new List<Port>();
var startSlot = startAnchor.userData as MaterialSlot;
if (startSlot == null)
return compatibleAnchors;

startStage = NodeUtils.FindEffectiveShaderStage(startSlot.owner, startSlot.isOutputSlot);
foreach (var candidateAnchor in anchors.ToList())
foreach (var candidateAnchor in ports.ToList())
{
var candidateSlot = candidateAnchor.userData as MaterialSlot;
if (!startSlot.IsCompatibleWith(candidateSlot))

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


if (slot.hidden)
continue;
var anchor = InstantiateNodeAnchor(Orientation.Horizontal, slot.isInputSlot ? Direction.Input : Direction.Output, typeof(Vector4));
var anchor = InstantiatePort(Orientation.Horizontal, slot.isInputSlot ? Direction.Input : Direction.Output, typeof(Vector4));
anchor.anchorName = slot.displayName;
anchor.portName = slot.displayName;
anchor.userData = slot;
if (slot.isOutputSlot)

public void UpdatePortInputTypes()
{
foreach (var anchor in inputContainer.Concat(outputContainer).OfType<NodeAnchor>())
foreach (var anchor in inputContainer.Concat(outputContainer).OfType<Port>())
anchor.anchorName = slot.displayName;
anchor.portName = slot.displayName;
}
foreach (var attacher in m_Attachers)

正在加载...
取消
保存