浏览代码

Fix hanging edges for collapsed nodes after undo/redo

Reduce the amount of `ValidateGraph()` calls when undo/redo'ing to 2 rather than once per node and edge per graph
/main
Peter Bay Bastian 7 年前
当前提交
17a5050c
共有 2 个文件被更改,包括 18 次插入5 次删除
  1. 20
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs
  2. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

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


return new Dictionary<SerializationHelper.TypeSerializationInfo, SerializationHelper.TypeSerializationInfo>();
}
public virtual IEdge Connect(SlotReference fromSlotRef, SlotReference toSlotRef)
IEdge ConnectNoValidate(SlotReference fromSlotRef, SlotReference toSlotRef)
{
if (fromSlotRef == null || toSlotRef == null)
return null;

AddEdgeToNodeEdges(newEdge);
Debug.Log("Connected edge: " + newEdge);
return newEdge;
}
public virtual IEdge Connect(SlotReference fromSlotRef, SlotReference toSlotRef)
{
var newEdge = ConnectNoValidate(fromSlotRef, toSlotRef);
ValidateGraph();
return newEdge;
}

removedNodeEdges.Add(edge);
}
foreach (var edge in removedNodeEdges)
RemoveEdge(edge);
RemoveEdgeNoValidate(edge);
}
// Remove all nodes and re-add them.

foreach (var node in m_Nodes.Values)
removedNodeGuids.Add(node.guid);
foreach (var nodeGuid in removedNodeGuids)
RemoveNode(m_Nodes[nodeGuid]);
RemoveNodeNoValidate(m_Nodes[nodeGuid]);
ValidateGraph();
AddNode(node);
AddNodeNoValidate(node);
}
// Add edges from other graph which don't exist in this one.

Connect(edge.outputSlot, edge.inputSlot);
ConnectNoValidate(edge.outputSlot, edge.inputSlot);
ValidateGraph();
}
public void OnEnable()

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


edgeView.input.Connect(edgeView);
m_GraphView.AddElement(edgeView);
sourceNodeView.RefreshAnchors();
targetNodeView.RefreshAnchors();
}
}

edgeView.input = targetAnchor;
edgeView.input.Connect(edgeView);
m_GraphView.AddElement(edgeView);
sourceNodeView.RefreshAnchors();
targetNodeView.RefreshAnchors();
}
}
}

正在加载...
取消
保存