public virtual void Destroy() { #if !FRB_MDX StateManager.Current.Activating -= ActivatingAction; StateManager.Current.Deactivating -= DeactivatingAction; #endif if (mLastLoadedScene != null) { mLastLoadedScene.Clear(); } FlatRedBall.Debugging.Debugger.DestroyText(); // It's common for users to forget to add Particle Sprites // to the mSprites SpriteList. This will either create leftover // particles when the next screen loads or will throw an assert when // the ScreenManager checks if there are any leftover Sprites. To make // things easier we'll just clear the Particle Sprites here. bool isPopup = this != ScreenManager.CurrentScreen; if (!isPopup) { SpriteManager.RemoveAllParticleSprites(); } if (UnloadsContentManagerWhenDestroyed && mContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.Unload(mContentManagerName); FlatRedBallServices.Clean(); } if (ShouldRemoveLayer && mLayer != null) { SpriteManager.RemoveLayer(mLayer); } if (IsPaused) { UnpauseThisScreen(); } GuiManager.Cursor.IgnoreNextClick = true; if (mNumberOfThreadsBeforeAsync != -1) { FlatRedBallServices.SetNumberOfThreadsToUse(mNumberOfThreadsBeforeAsync); } if (ScreenDestroy != null) { ScreenDestroy(); } }
public virtual void Destroy() { #if !FRB_MDX StateManager.Current.Activating -= ActivatingAction; StateManager.Current.Deactivating -= DeactivatingAction; #endif if (mLastLoadedScene != null) { mLastLoadedScene.Clear(); } FlatRedBall.Debugging.Debugger.DestroyText(); // All of the popups should be destroyed as well foreach (Screen s in mPopups) { s.Destroy(); } SpriteManager.RemoveSpriteList <Sprite>(mSprites); // It's common for users to forget to add Particle Sprites // to the mSprites SpriteList. This will either create leftover // particles when the next screen loads or will throw an assert when // the ScreenManager checks if there are any leftover Sprites. To make // things easier we'll just clear the Particle Sprites here. bool isPopup = this != ScreenManager.CurrentScreen; if (!isPopup) { SpriteManager.RemoveAllParticleSprites(); } // Destory all SpriteGrids that belong to this Screen foreach (SpriteGrid sg in mSpriteGrids) { sg.Destroy(); } // Destroy all SpriteFrames that belong to this Screen while (mSpriteFrames.Count != 0) { SpriteManager.RemoveSpriteFrame(mSpriteFrames[0]); } if (UnloadsContentManagerWhenDestroyed && mContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.Unload(mContentManagerName); FlatRedBallServices.Clean(); } if (ShouldRemoveLayer && mLayer != null) { SpriteManager.RemoveLayer(mLayer); } if (IsPaused) { UnpauseThisScreen(); } GuiManager.Cursor.IgnoreNextClick = true; }