Exemplo n.º 1
0
        public static void RemoveModel(VFXModel model, bool notify = true)
        {
            VFXGraph graph = model.GetGraph();

            if (graph != null)
            {
                graph.UIInfos.Sanitize(graph); // Remove reference from groupInfos
            }
            UnlinkModel(model);
            model.Detach(notify);
        }
Exemplo n.º 2
0
        public static void ReplaceModel(VFXModel dst, VFXModel src, bool notify = true)
        {
            // UI
            dst.m_UIPosition       = src.m_UIPosition;
            dst.m_UICollapsed      = src.m_UICollapsed;
            dst.m_UISuperCollapsed = src.m_UISuperCollapsed;

            if (notify)
            {
                dst.Invalidate(InvalidationCause.kUIChanged);
            }

            VFXGraph graph = src.GetGraph();

            if (graph != null && graph.UIInfos != null && graph.UIInfos.groupInfos != null)
            {
                // Update group nodes
                foreach (var groupInfo in graph.UIInfos.groupInfos)
                {
                    if (groupInfo.contents != null)
                    {
                        for (int i = 0; i < groupInfo.contents.Length; ++i)
                        {
                            if (groupInfo.contents[i].model == src)
                            {
                                groupInfo.contents[i].model = dst;
                            }
                        }
                    }
                }
            }

            if (dst is VFXBlock && src is VFXBlock)
            {
                ((VFXBlock)dst).enabled = ((VFXBlock)src).enabled;
            }

            // Unlink everything
            UnlinkModel(src);

            // Replace model
            var parent = src.GetParent();
            int index  = parent.GetIndex(src);

            src.Detach(notify);

            if (parent)
            {
                parent.AddChild(dst, index, notify);
            }
        }
Exemplo n.º 3
0
        public void AddChild(VFXModel model, int index = -1, bool notify = true)
        {
            int realIndex = index == -1 ? m_Children.Count : index;

            if (model.m_Parent != this || realIndex != GetIndex(model))
            {
                if (!AcceptChild(model, index))
                {
                    throw new ArgumentException("Cannot attach " + model + " to " + this);
                }

                model.Detach(notify && model.m_Parent != this);     // Dont notify if the owner is already this to avoid double invalidation
                realIndex = index == -1 ? m_Children.Count : index; // Recompute as the child may have been removed

                m_Children.Insert(realIndex, model);
                model.m_Parent = this;
                model.OnAdded();

                if (notify)
                {
                    Invalidate(InvalidationCause.kStructureChanged);
                }
            }
        }
Exemplo n.º 4
0
        public static void ReplaceModel(VFXModel dst, VFXModel src, bool notify = true)
        {
            // UI
            dst.m_UIPosition       = src.m_UIPosition;
            dst.m_UICollapsed      = src.m_UICollapsed;
            dst.m_UISuperCollapsed = src.m_UISuperCollapsed;

            if (notify)
            {
                dst.Invalidate(InvalidationCause.kUIChanged);
            }

            VFXGraph graph = src.GetGraph();

            if (graph != null && graph.UIInfos != null && graph.UIInfos.groupInfos != null)
            {
                // Update group nodes
                foreach (var groupInfo in graph.UIInfos.groupInfos)
                {
                    if (groupInfo.contents != null)
                    {
                        for (int i = 0; i < groupInfo.contents.Length; ++i)
                        {
                            if (groupInfo.contents[i].model == src)
                            {
                                groupInfo.contents[i].model = dst;
                            }
                        }
                    }
                }
            }

            if (dst is VFXBlock && src is VFXBlock)
            {
                ((VFXBlock)dst).enabled = ((VFXBlock)src).enabled;
            }

            // Unlink everything
            if (src is IVFXSlotContainer)
            {
                var     slotContainer = src as IVFXSlotContainer;
                VFXSlot slotToClean   = null;
                do
                {
                    slotToClean = slotContainer.inputSlots.Concat(slotContainer.outputSlots).FirstOrDefault(o => o.HasLink(true));
                    if (slotToClean)
                    {
                        slotToClean.UnlinkAll(true, true);
                    }
                }while (slotToClean != null);
            }

            // Replace model
            var parent = src.GetParent();
            int index  = parent.GetIndex(src);

            src.Detach(notify);

            if (parent)
            {
                parent.AddChild(dst, index, notify);
            }
        }