How can I build content files (xnb) and load them at runtime, without adding them to the content manager upfront (lets say I want to allow users to add their own files after game release and game to adapt and load them dynamically)?
All the docs / old posts I found on this are either very old or lack in documentation… must have missed something
Thanks!
On the other hand you can e.g. load textures from .png-files as well (which is slower though). So you don’t really need to build the content.
Let’s say you want your player to be able to set his custom profile-picture. You could have a folder where the user can put .png-files that will be loaded at startup.
This is also possible, but then he needs to manually dispose those textures, because they are not loaded and managed by the ContentManager.
I think it depends on what he is trying to achieve. If he wants to have full modding support for his game or if he creates an editor kind of software, I would recommend using the MGCB.
If it’s just a single picture like for a profile, then just loading the png from stream and manually dispose it later is of course simpler.
@BlizzCrafter@Finnhax thank you for the replies @BlizzCrafter is close to what I want, not exactly an editor but sometimes that let users add whatever they like, sounds and models included.
So I understand my best shot is to just invoke the exe from my code, knowing it will only work on windows / linux / Mac? Is there a more “programmable” way to do it via one of MonoGame’s APIs?
I am also a little late, I was on holiday, well that’s my excuse.
Anyway, I had the same problem. The way I solved it was to write a class that extends ContentManager.
From within this you can still use pre-built content, but if the content is not there you can fall back to manual loading.
At the moment I am handling my custom content types this way instead of using a new content importer, and I handle textures by loading them into memory and then creating a Texture2D from the MemoryStream.
The reason I do this is two fold.
I am streaming content on a background thread.
The game is designed to be modded after release.
It actual fact it is very easy to do and although slower than using pre-built assets works incredibly well.