Exemplo n.º 1
0
 public static void UnlinkModel(VFXModel model, bool notify = true)
 {
     if (model is IVFXSlotContainer)
     {
         var     slotContainer = (IVFXSlotContainer)model;
         VFXSlot slotToClean   = null;
         do
         {
             slotToClean = slotContainer.inputSlots.Concat(slotContainer.outputSlots).FirstOrDefault(o => o.HasLink(true));
             if (slotToClean)
             {
                 slotToClean.UnlinkAll(true, notify);
             }
         }while (slotToClean != null);
     }
 }
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
            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);
            }
        }