Programmatic access to mgcb file...

Hi Monogamers!

Quick Q: How does one go about making new entries to the Content.mgcb file without having to physically go in and make the entries? I would like to export data directly from the game, into the content file. For example, lets say I want to enable a photo function that captures in game screenshots, and writes the file directly to an xnb file to be referenced at a later time.

Quick Edit : It looks like this is achieved using the ContentTypeWriter if I’m not mistaken. Though I am not sure if this actually results in a entry in the mgcb, or just a new .xnb file…

Thanks!

http://www.monogame.net/documentation/?page=T_Microsoft_Xna_Framework_Content_Pipeline_Serialization_Compiler_ContentCompiler

MGCB is more for the Visual Studio side of things, but I think the compiler is more for runtime time?

This has me intrigued…

Creating a XNB file at runtime, you need to add the Content Pipeline assembly and required executable libraries and executables to your project.

If you are just capturing and saving screenshots, use Texture2D.SaveAsJpeg and Texture2D.SaveAsPng. Then use Texture2D.FromStream to load them again later.

1 Like