Skip to main content
GameDev.net gamedev.net
🔒 Locked

XNA - what needs to go in UnloadContent()?

Started by lsdogsdnbgj Oct 2, 2019 at 2:00 PM 2 replies 2.8k views
Original Post
lsdogsdnbgj
lsdogsdnbgj

Hey everyone,

I'm working on an XNA (well, MonoGame) app and I'm wondering what needs to go in the auto-generated UnloadContent() method?

Most of my models, textures, effects, etc... are loaded from ContentManager and so don't need to be manually unloaded. I do have a few tiny things that I'm creating myself though - for example, a couple of 1x1 Texture2Ds which I use for rendering coloured rectangles and lines via SpriteBatch, and a RenderTarget2D that I use for my shadow mapping.

What's your rule for when something needs to go into UnloadContent(), and what should I actually do with it there?

Thanks so much!

tracegame
tracegame

Just reply in another thread,check here.


lsdogsdnbgj
lsdogsdnbgj

Thanks for the info - I did some more research and the general agreement seems to be that any content I create outside of ContentManager should have its Dispose() method called when I'm done with it. So now, in the UnloadContent() method, I call Dispose() on all the Texture2Ds that I create manually (and I leave the ContentManager to do its thing with its own Textures, Models, Effects, etc...)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.