Ejemplo n.º 1
0
            void CopyPasteNodes()
            {
                object result = VFXCopy.Copy(m_SourceControllers, m_Rect);

                VFXPaste.Paste(m_TargetController, m_Rect.center, result, null, null, m_TargetControllers);
                List <VFXParameterController> targetParameters = new List <VFXParameterController>();
            }
Ejemplo n.º 2
0
 public static void Paste(VFXViewController viewController, Vector2 center, object data, VFXView view, VFXGroupNodeController groupNode, List <VFXNodeController> nodesInTheSameOrder = null)
 {
     if (s_Instance == null)
     {
         s_Instance = new VFXPaste();
     }
     s_Instance.DoPaste(viewController, center, data, view, groupNode, nodesInTheSameOrder);
 }
Ejemplo n.º 3
0
            public void ConvertToSubgraphBlock(VFXView sourceView, IEnumerable <Controller> controllers, Rect rect)
            {
                this.m_Rect = rect;
                Init(sourceView, controllers);
                CreateUniqueSubgraph("SubgraphBlock", VisualEffectSubgraphBlock.Extension, VisualEffectAssetEditorUtility.CreateNew <VisualEffectSubgraphBlock>);

                m_SourceControllers.RemoveAll(t => t is VFXContextController); // Don't copy contexts
                CopyPasteNodes();

                m_SourceBlockControllers = m_SourceControllers.OfType <VFXBlockController>().OrderBy(t => t.index).ToList();

                VFXContextController sourceContextController = m_SourceBlockControllers.First().contextController;

                object copyData = VFXCopy.CopyBlocks(m_SourceBlockControllers);

                var targetContext = m_TargetController.graph.children.OfType <VFXBlockSubgraphContext>().FirstOrDefault();

                if (targetContext == null)
                {
                    targetContext = ScriptableObject.CreateInstance <VFXBlockSubgraphContext>();
                    m_TargetController.graph.AddChild(targetContext);
                }
                m_TargetController.LightApplyChanges();
                targetContext.position = sourceContextController.position;
                targetContext.SetSettingValue("m_SuitableContexts", (VFXBlockSubgraphContext.ContextType)m_SourceBlockControllers.Select(t => t.model.compatibleContexts).Aggregate((t, s) => t & s));
                m_TargetBlocks = new List <VFXBlockController>();

                VFXPaste.PasteBlocks(m_TargetController, copyData, targetContext, 0, m_TargetBlocks);

                var otherSourceControllers = m_SourceControllers.OfType <VFXNodeController>().Where(t => !(t is VFXBlockController)).ToList();

                //Create lost links between nodes and blocks
                foreach (var edge in m_SourceController.dataEdges.Where(t => otherSourceControllers.Contains(t.output.sourceNode) && m_SourceBlockControllers.Contains(t.input.sourceNode)))
                {
                    var outputNode = m_TargetControllers[m_SourceControllers.IndexOf(edge.output.sourceNode)];
                    var output     = outputNode.outputPorts.First(t => t.path == edge.output.path);

                    var inputBlock = m_TargetBlocks[m_SourceBlockControllers.IndexOf(edge.input.sourceNode as VFXBlockController)];
                    var input      = inputBlock.inputPorts.First(t => t.path == edge.input.path);

                    m_TargetController.CreateLink(input, output);
                }

                var sourceBlock = ScriptableObject.CreateInstance <VFXSubgraphBlock>();

                m_SourceNode = sourceBlock;
                sourceContextController.model.AddChild(m_SourceNode, m_SourceBlockControllers.Select(t => t.index).Min());
                sourceContextController.ApplyChanges();
                m_SourceNodeController = sourceContextController.blockControllers.First(t => t.model == m_SourceNode);
                PostSetup();
                m_SourceNodeController.ApplyChanges();

                var targetContextController = m_TargetController.GetRootNodeController(targetContext, 0) as VFXContextController;

                m_SourceControllersWithBlocks = m_SourceControllers.Concat(m_SourceBlockControllers);
                TransferEdges();
                UninitSmart();
            }
Ejemplo n.º 4
0
        public static void PasteBlocks(VFXViewController viewController, object data, VFXContext targetModelContext, int targetIndex, List <VFXBlockController> blocksInTheSameOrder)
        {
            if (s_Instance == null)
            {
                s_Instance = new VFXPaste();
            }

            s_Instance.PasteBlocks(viewController, (data as SerializableGraph).operators, targetModelContext, targetIndex, blocksInTheSameOrder);
        }
Ejemplo n.º 5
0
        public static void UnserializeAndPasteElements(VFXViewController viewController, Vector2 center, string data, VFXView view = null, VFXGroupNodeController groupNode = null)
        {
            var serializableGraph = JsonUtility.FromJson <SerializableGraph>(data);

            if (s_Instance == null)
            {
                s_Instance = new VFXPaste();
            }
            s_Instance.DoPaste(viewController, center, serializableGraph, view, groupNode, null);
        }
Ejemplo n.º 6
0
            void CopyPasteOperators(Dictionary <VFXNodeController, VFXNodeController> targetNodes)
            {
                m_SourceOperatorAndParameters = m_SourceControllers.OfType <VFXNodeController>().Where(t => !(t is VFXBlockController)).ToList();
                object result = VFXCopy.Copy(m_SourceOperatorAndParameters, m_Rect);

                m_TargetOperatorAndParameters = new List <VFXNodeController>();
                VFXPaste.Paste(m_TargetController, m_Rect.center, result, null, null, m_TargetOperatorAndParameters);

                foreach (var st in m_SourceOperatorAndParameters.Zip(m_TargetOperatorAndParameters, (s, t) => new { source = s, target = t }))
                {
                    targetNodes[st.source] = st.target;
                }
            }
Ejemplo n.º 7
0
        internal void BlocksDropped(int blockIndex, IEnumerable <VFXBlockController> draggedBlocks, bool copy)
        {
            //Sort draggedBlock in the order we want them to appear and not the selected order ( blocks in the same context should appear in the same order as they where relative to each other).
            draggedBlocks = draggedBlocks.OrderBy(t => t.index).GroupBy(t => t.contextController).SelectMany <IGrouping <VFXContextController, VFXBlockController>, VFXBlockController>(t => t.Select(u => u));

            if (copy)
            {
                var copiedBlocks = VFXCopy.CopyBlocks(draggedBlocks);
                VFXPaste.PasteBlocks(viewController, copiedBlocks, model, blockIndex);
            }
            else
            {
                foreach (VFXBlockController draggedBlock in draggedBlocks)
                {
                    this.ReorderBlock(blockIndex++, draggedBlock.model);
                }
            }
        }