Ejemplo n.º 1
0
        /// <summary>
        /// Called when graphics resources need to be unloaded. Override this method to unload any game-specific graphics resources.
        /// </summary>
        public override void UnloadContent()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::UnloadContent");
            MyMwcLog.WriteLine("MyMinerGame.UnloadContent() - START");
            MyMwcLog.IncreaseIndent();

            if (m_debugFont != null)
            {
                m_debugFont.Dispose();
                m_debugFont = null;
            }

            if (DefaultSurface != null)
            {
                DefaultSurface.Dispose();
                DefaultSurface = null;
            }
            if (DefaultDepth != null)
            {
                DefaultDepth.Dispose();
                DefaultDepth = null;
            }

            // GUI
            MyGuiManager.UnloadContent();

            MyRender.UnloadContent();

            MyTextureManager.UnloadContent();
            MyModels.UnloadContent();

            // Global content
            //Content.Unload();

            // Render
            MySunGlare.UnloadContent();

            MyDebugDrawCachedLines.UnloadContent();
            MyDebugDraw.UnloadContent();

            //MyRender.UnloadContent(); //it is unloaded in gui gameplay screen

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyMinerGame.UnloadContent() - END");

            GraphicsDevice.SetStreamSource(0, null, 0, 0);
            GraphicsDevice.Indices           = null;
            GraphicsDevice.VertexDeclaration = null;
            GraphicsDevice.PixelShader       = null;
            GraphicsDevice.VertexShader      = null;
            for (int i = 0; i < 16; i++)
            {
                GraphicsDevice.SetTexture(i, null);
            }

            base.UnloadContent();

            GC.Collect();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }