public override void OnModuleDeactivate()
 {
     if (m_RectsCache != null)
     {
         undoSystem.ClearUndo(m_RectsCache);
         ScriptableObject.DestroyImmediate(m_RectsCache);
         m_RectsCache = null;
     }
     undoSystem.UnregisterUndoCallback(UndoCallback);
     RemoveMainUI(spriteEditor.GetMainVisualContainer());
 }
        // implements ISpriteEditorModule

        public override void OnModuleActivate()
        {
            spriteImportMode      = SpriteFrameModule.GetSpriteImportMode(spriteEditor.GetDataProvider <ISpriteEditorDataProvider>());
            m_TextureDataProvider = spriteEditor.GetDataProvider <ITextureDataProvider>();
            m_SpriteDataProvider  = spriteEditor.GetDataProvider <ISpriteEditorDataProvider>();
            int width, height;

            m_TextureDataProvider.GetTextureActualWidthAndHeight(out width, out height);
            textureActualWidth       = width;
            textureActualHeight      = height;
            m_RectsCache             = ScriptableObject.CreateInstance <SpriteRectModel>();
            m_RectsCache.hideFlags   = HideFlags.HideAndDontSave;
            m_RectsCache.spriteRects = m_SpriteDataProvider.GetSpriteRects().ToList();
            spriteEditor.spriteRects = m_RectsCache.spriteRects;
            if (spriteEditor.selectedSpriteRect != null)
            {
                spriteEditor.selectedSpriteRect = m_RectsCache.spriteRects.FirstOrDefault(x => x.spriteID == spriteEditor.selectedSpriteRect.spriteID);
            }
            AddMainUI(spriteEditor.GetMainVisualContainer());
            undoSystem.RegisterUndoCallback(UndoCallback);
        }