Texture pack system like minecraft

Hello everyone, I have been using monogame for a while now and I ran into a problem, I’d like to implement a way for players and content creators to change textures like with ressource packs in Minecraft.
But with the Content.mgcb Pipeline, I don’t know how to implement this since the textures are precompiled.

I would like to set up a way for players to drag and drop the .png files in a folder inside the save and the game could load them directly.

Is this possible in Monogame?
Thank you in advance for your answers.

You can use .png instead of compiled .xnb files using stream. Check Texture2D.FromStream(…)

Creates a Texture2D from a stream, supported formats bmp, gif, jpg, png, tif and dds (only for simple textures). May work with other formats, but will not work with tga files.

Example from stackoverflow:

string FilePath = "file.png";
FileStream titleStream = File.OpenRead(FilePath);
texture = Texture2D.FromStream(device, titleStream);
titleStream.Close();

Thank you for the quick answer, this was exactly what I needed and works very well. :grin:

1 Like

I have such a system in Exipelago (but it also features Editors to configure more than just the texture)

As shown above, you have to load manually.

Be aware tho, that this will not create MipMaps or anything, you’d have to create those yourself. If I remember correctly, I just render the texture with a flag (to generate mipmaps) onto a rendertarget of the same size of of the texture just copy those from the rendertarget… (all during loading)

You can spare that if you don’t need MipMaps