浏览代码

Make edges preserved when copying a property node that is converted to a concrete node

/main
Jens Holm 7 年前
当前提交
c5caad3e
共有 1 个文件被更改,包括 17 次插入20 次删除
  1. 37
      com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs

37
com.unity.shadergraph/Editor/Data/Graphs/AbstractMaterialGraph.cs


internal void PasteGraph(CopyPasteGraph graphToPaste, List<INode> remappedNodes, List<IEdge> remappedEdges)
{
var nodesToPaste = new List<INode>();
var nodeGuidMap = new Dictionary<Guid, Guid>();
// If the pasted node is a property node, convert it into a concrete node
// if the associated property does not exist.
INode pastedNode = node;
var oldGuid = node.guid;
var newGuid = node.RewriteGuid();
// Check if the property nodes need to be made into a concrete node.
if (node is PropertyNode)
{
PropertyNode propertyNode = (PropertyNode)node;

var pastedGraphMetaProperties = graphToPaste.metaProperties.Where(x => x.guid == propertyNode.propertyGuid);
if (pastedGraphMetaProperties.Any())
{
INode concreteNode = pastedGraphMetaProperties.FirstOrDefault().ToConcreteNode();
concreteNode.drawState = node.drawState;
nodesToPaste.Add(concreteNode);
continue;
pastedNode = pastedGraphMetaProperties.FirstOrDefault().ToConcreteNode();
pastedNode.drawState = node.drawState;
nodeGuidMap[oldGuid] = pastedNode.guid;
nodesToPaste.Add(node);
}
var nodeGuidMap = new Dictionary<Guid, Guid>();
foreach (var node in nodesToPaste)
{
var oldGuid = node.guid;
var newGuid = node.RewriteGuid();
nodeGuidMap[oldGuid] = newGuid;
else
{
nodeGuidMap[oldGuid] = newGuid;
}
var drawState = node.drawState;
var position = drawState.position;

node.drawState = drawState;
remappedNodes.Add(node);
AddNode(node);
remappedNodes.Add(pastedNode);
AddNode(pastedNode);
m_PastedNodes.Add(node);
m_PastedNodes.Add(pastedNode);
}
// only connect edges within pasted elements, discard

正在加载...
取消
保存