Example #1
0
        private void CopyNodes()
        {
            Graph copy = new Graph();

            copy.serializationData = this.m_Graph.serializationData;
            for (int i = 0; i < this.m_Selection.Count; i++)
            {
                copy.serializationData.Replace(this.m_Selection[i].id, System.Guid.NewGuid().ToString());
            }
            GraphUtility.Load(copy);
            Node[] toDelete = copy.nodes.Where(x => !this.m_Selection.Exists(y => x.id == y.id)).ToArray();
            GraphUtility.RemoveNodes(copy, toDelete.Cast <FlowNode>().ToArray());
            GraphUtility.Save(copy);
            this.m_Copy = copy.serializationData;
        }
        private void PasteNodes(Vector2 position)
        {
            if (!string.IsNullOrEmpty(this.m_Copy))
            {
                this.m_Selection.Clear();
                Graph graph = new Graph();
                graph.serializationData = this.m_Copy;
                GraphUtility.Load(graph);

                for (int i = 0; i < graph.nodes.Count; i++)
                {
                    Node node = graph.nodes[i];
                    if (position == Vector2.zero)
                    {
                        position = node.position + new Vector2(20, 15);
                    }
                    node.position += position - node.position;
                    this.m_Graph.nodes.Add(node);
                    this.m_Selection.Add((FlowNode)node);
                }
                GraphUtility.Save(this.m_Graph);
                PrefabUtility.RecordPrefabInstancePropertyModifications(this.m_Target);
            }
        }
 public void OnAfterDeserialize()
 {
     GraphUtility.Load(this);
 }