MonoGame / MonoGame

One framework for creating powerful cross-platform games.
http://www.monogame.net
Other
11.49k stars 2.92k forks source link

Unloading individual content #6164

Open kimimaru4000 opened 6 years ago

kimimaru4000 commented 6 years ago

MonoGame currently does not support unloading content individually, which is a feature I feel can be useful for a variety of reasons. I'll list several use-cases:

  1. Playing a cutscene that has one new asset that needs to be loaded just for that cutscene.
  2. Unloading a single shader that no longer needs to be used.
  3. Wanting to unload some assets without unloading every asset.

These can be done with multiple ContentManagers, but that seems overkill if you have only a few assets that you'd need for a specific purpose.

I suggest we can either add an overload to Unload with the following signature:

public virtual void Unload(string assetName)

or add a new method:

public virtual void UnloadAsset(string assetName)

Thoughts?

kimimaru4000 commented 5 years ago

I'm going to look more into this. @Jjagg I vaguely recall a while back you said that models may be problematic because this method would have to also unload anything related to them, such as textures. What if we make it clear that it's unloading only a single asset and not anything else?

Jjagg commented 5 years ago

I'm fine with adding the method. It's something that comes up every once in a while.

This has been a discussion point before though, so I'd like other people to weigh in.

@tomspilman @cra0zy

mrhelmut commented 5 years ago

Definitely something that would prove useful. I keep hearing from devs who re-implement their own content manager because of this.

harry-cpp commented 5 years ago

Agreed.