浏览代码

[shader graph] Fix edge connection so that it removes input edges before connecting new input edges.

/main
Tim Cooper 9 年前
当前提交
d0d0f462
共有 2 个文件被更改,包括 32 次插入5 次删除
  1. 34
      UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs
  2. 3
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs

34
UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs


public override Edge Connect(Slot fromSlot, Slot toSlot)
{
var edge = base.Connect(fromSlot, toSlot);
Slot outputSlot = null;
Slot inputSlot = null;
// output must connect to input
if (fromSlot.isOutputSlot)
outputSlot = fromSlot;
else if (fromSlot.isInputSlot)
inputSlot = fromSlot;
if (toSlot.isOutputSlot)
outputSlot = toSlot;
else if (toSlot.isInputSlot)
inputSlot = toSlot;
if (inputSlot == null || outputSlot == null)
return null;
// remove any inputs that exits before adding
foreach (var edge in inputSlot.edges.ToArray())
{
Debug.Log("Removing edge:" + edge);
// call base here as we DO NOT want to
// do expensive shader regeneration
base.RemoveEdge(edge);
}
var newEdge = base.Connect(fromSlot, toSlot);
Debug.Log("Connected edge: " + newEdge);
return edge;
return newEdge;
return edge;
return newEdge;
}
public override void AddNode(Node node)

3
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs


}
e.ParentCanvas().ReloadData();
e.ParentCanvas().Repaint();
Debug.Log("Connecting: " + a + " " + b);
//m_Elements.Add();
}
}
}
正在加载...
取消
保存