Exemplo n.º 1
0
        NodeID CopyContext(ref Context context, VFXContextController controller, int index)
        {
            NodeID id = CopyNode(ref context.node, controller.model, (NodeID)index);

            var blocks = controller.blockControllers;

            context.label = controller.model.label;

            if (controller.model.GetData() != null)
            {
                context.dataIndex = Array.IndexOf(datas, controller.model.GetData());
            }
            else
            {
                context.dataIndex = -1;
            }
            context.blocks = CopyBlocks(controller.blockControllers, index);
            context.node.indexInClipboard = contextsIndices[index];

            if (controller.model is VFXAbstractRenderedOutput)
            {
                context.subOutputs = CopySubOutputs(((VFXAbstractRenderedOutput)controller.model).GetSubOutputs());
            }
            else
            {
                context.subOutputs = null;
            }

            return(id);
        }
Exemplo n.º 2
0
 public VFXBlockController(VFXBlock model, VFXContextController contextController) : base(model, contextController.viewController)
 {
     m_ContextController = contextController;
     if (model is VFXSubgraphBlock)
     {
         model.Invalidate(VFXModel.InvalidationCause.kSettingChanged); // Simulate a settings change in case the subgraph parameters has changed.
     }
 }
Exemplo n.º 3
0
 public VFXBlockController(VFXBlock model, VFXContextController contextController) : base(model, contextController.viewController)
 {
     m_ContextController = contextController;
     if (model is VFXSubgraphBlock)
     {
         (model as VFXSubgraphBlock).RecreateCopy();
     }
 }
Exemplo n.º 4
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();
            }
 public VFXBlockController(VFXBlock model, VFXContextController contextController) : base(model, contextController.viewController)
 {
     m_ContextController = contextController;
     if (model is VFXSubgraphBlock)
     {
         // Prevent breaking the editor opening.
         try
         {
             (model as VFXSubgraphBlock).RecreateCopy();
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
 }
Exemplo n.º 6
0
        NodeID CopyContext(ref Context context, VFXContextController controller, int index)
        {
            NodeID id = CopyNode(ref context.node, controller.model, (NodeID)index);

            var blocks = controller.blockControllers;

            if (controller.model.GetData() != null)
            {
                context.dataIndex = Array.IndexOf(datas, controller.model.GetData());
            }
            else
            {
                context.dataIndex = -1;
            }
            context.blocks = CopyBlocks(controller.blockControllers, index);

            return(id);
        }
Exemplo n.º 7
0
        private void RegisterContexts(VFXViewController viewController)
        {
            for (int i = 0; i < newContexts.Count; ++i)
            {
                if (newContexts[i].Key != null)
                {
                    VFXContextController controller = viewController.GetNodeController(newContexts[i].Key, 0) as VFXContextController;
                    newControllers[ContextFlag | (uint)i] = controller;

                    for (int j = 0; j < newContexts[i].Value.Count; ++j)
                    {
                        var block = newContexts[i].Value[j];
                        if (block != null)
                        {
                            VFXBlockController blockController = controller.blockControllers.First(t => t.model == block);
                            if (blockController != null)
                            {
                                newControllers[GetBlockID((uint)i, (uint)j)] = blockController;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
 public VFXBlockController(VFXBlock model, VFXContextController contextController) : base(model, contextController.viewController)
 {
     m_ContextController = contextController;
 }
Exemplo n.º 9
0
 public VFXBlockProvider(VFXContextController context, Action <VFXModelDescriptor <VFXBlock>, Vector2> onAddBlock) : base(onAddBlock)
 {
     m_ContextController = context;
 }
 public void Init(VFXContextController context, int slotIndex)
 {
     m_Context   = context;
     m_SlotIndex = slotIndex;
 }
Exemplo n.º 11
0
        void IEdgeConnectorListener.OnDropOutsidePort(Edge edge, Vector2 position)
        {
            VFXView           view           = this.GetFirstAncestorOfType <VFXView>();
            VFXViewController viewController = view.controller;


            VFXContextUI endContext = null;

            foreach (var node in view.GetAllContexts())
            {
                if (node.worldBound.Contains(position))
                {
                    endContext = node;
                }
            }

            VFXFlowEdge flowEdge = edge as VFXFlowEdge;
            bool        exists   = false;

            if (flowEdge.controller != null)
            {
                view.controller.RemoveElement(flowEdge.controller);
                exists = true;
            }

            if (endContext != null)
            {
                VFXContextController nodeController = endContext.controller;

                var compatibleAnchors = viewController.GetCompatiblePorts(controller, null);

                if (controller.direction == Direction.Input)
                {
                    foreach (var outputAnchor in nodeController.flowOutputAnchors)
                    {
                        if (compatibleAnchors.Contains(outputAnchor))
                        {
                            VFXFlowEdgeController edgeController = new VFXFlowEdgeController(controller, outputAnchor);

                            viewController.AddElement(edgeController);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var inputAnchor in nodeController.flowInputAnchors)
                    {
                        if (compatibleAnchors.Contains(inputAnchor))
                        {
                            VFXFlowEdgeController edgeController = new VFXFlowEdgeController(inputAnchor, controller);

                            viewController.AddElement(edgeController);
                            break;
                        }
                    }
                }
            }
            else if (!exists)
            {
                VFXFilterWindow.Show(VFXViewWindow.currentWindow, Event.current.mousePosition - new Vector2(376 * 0.5f * VFXViewWindow.currentWindow.graphView.scale, 0), view.ViewToScreenPosition(Event.current.mousePosition), new VFXNodeProvider(viewController, AddLinkedContext, ProviderFilter, new Type[] { typeof(VFXContext) }));
            }
        }