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); }
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); } }
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); } }