|
|
|
|
|
|
Add(content); |
|
|
|
} |
|
|
|
|
|
|
|
List<INode> nodesToRemove = new List<INode>(); |
|
|
|
List<IEdge> edgesToRemove = new List<IEdge>(); |
|
|
|
|
|
|
|
if (graphViewChange.elementsToRemove != null) |
|
|
|
{ |
|
|
|
m_Graph.owner.RegisterCompleteObjectUndo("Delete"); |
|
|
|
foreach (var element in graphViewChange.elementsToRemove) |
|
|
|
{ |
|
|
|
var nodeView = element as MaterialNodeView; |
|
|
|
if (nodeView != null && nodeView.node != null) |
|
|
|
nodesToRemove.Add(nodeView.node); |
|
|
|
|
|
|
|
var edgeView = element as Edge; |
|
|
|
if (edgeView != null) |
|
|
|
{ |
|
|
|
var edge = edgeView.userData as IEdge; |
|
|
|
if (edge != null) |
|
|
|
edgesToRemove.Add(edge); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_Graph.RemoveElements(nodesToRemove, edgesToRemove); |
|
|
|
graphViewChange.elementsToRemove.Clear(); |
|
|
|
nodesToRemove.Clear(); |
|
|
|
edgesToRemove.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
m_Graph.owner.RegisterCompleteObjectUndo("Connect Edge"); |
|
|
|
{ |
|
|
|
m_Graph.owner.RegisterCompleteObjectUndo("Connect Edge"); |
|
|
|
} |
|
|
|
} |
|
|
|
graphViewChange.edgesToCreate.Clear(); |
|
|
|
} |
|
|
|
|
|
|
Edge AddEdge(IEdge edge) |
|
|
|
{ |
|
|
|
var sourceNode = m_Graph.GetNodeFromGuid(edge.outputSlot.nodeGuid); |
|
|
|
if (sourceNode == null) |
|
|
|
{ |
|
|
|
Debug.LogWarning("Source node is null"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
if (targetNode == null) |
|
|
|
{ |
|
|
|
Debug.LogWarning("Target node is null"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
var targetSlot = targetNode.FindInputSlot<MaterialSlot>(edge.inputSlot.slotId); |
|
|
|
|
|
|
|
var sourceNodeView = m_GraphView.nodes.ToList().OfType<MaterialNodeView>().FirstOrDefault(x => x.node == sourceNode); |
|
|
|