浏览代码

Undo fix

/main
Peter Bay Bastian 7 年前
当前提交
4f1b32b9
共有 1 个文件被更改,包括 5 次插入16 次删除
  1. 21
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs

21
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs


public virtual void ReplaceWith(IGraph other)
{
// Current tactic is to remove all nodes and edges and then re-add them, such that depending systems
// will re-initialize with new references.
{
// Remove the edge if it doesn't exist in the other graph.
if (!other.ContainsNodeGuid(edge.inputSlot.nodeGuid) || !other.GetEdges(edge.inputSlot).Any(otherEdge => otherEdge.outputSlot.Equals(edge.outputSlot)))
removedNodeEdges.Add(edge);
}
removedNodeEdges.Add(edge);
// Remove all nodes and re-add them.
using (var removedNodesPooledObject = ListPool<Guid>.GetDisposable())
{
var removedNodeGuids = removedNodesPooledObject.value;

ValidateGraph();
// Add nodes from other graph which don't exist in this one.
{
if (!ContainsNodeGuid(node.guid))
AddNodeNoValidate(node);
}
AddNodeNoValidate(node);
// Add edges from other graph which don't exist in this one.
{
if (!GetEdges(edge.inputSlot).Any(otherEdge => otherEdge.outputSlot.Equals(edge.outputSlot)))
ConnectNoValidate(edge.outputSlot, edge.inputSlot);
}
ConnectNoValidate(edge.outputSlot, edge.inputSlot);
ValidateGraph();
}

正在加载...
取消
保存