using Mono-Game,

  • i have some custom content files in some binary format (not .xnb)

  • in run-time i need to read the content of those files.

  • i prefer to get a stream, but if something will give me a filled byte[] or something, that's also fine..

  • this must be cross-platform as much as possible and work on PC \ Mobile \ consoles \ web \ what-ever-mono-game-offers


my efforts so far :

  • ContentManager.Load() does not read custom formats

  • subclassing ContentManager, and overriding OpenStream(string assetName) did not help - it expects the file i give it to end with .xnb

  • renaming all files to ".xnb" just for this is not possible for me, because some other proccess reads thease files and expects them the way they are

  • TitleContainer.OpenStream() seems to read files from the file system, but im not sure how they will be packed when building for mobile devices for example.

    (i know that in unity: for android, content is simply copied to a folder on the device, but on iphone all content is packed to a binary package.. so reading from the file-system will not work)

    (i dont have an iphone\ipad to test this on)

  • the simple "File.ReadAllBytes()" is no good for the same reason


My questions are :

  1. am i right about TitleContainer's cross-platform limitation ?
  2. what can i do ?


  • \$\begingroup\$ what format are those files in ? \$\endgroup\$
    – dimitris93
    Commented May 5, 2015 at 16:55
  • \$\begingroup\$ different formats, some are .png .mp3 .txt , some are unique binary formats \$\endgroup\$
    – Levan
    Commented May 5, 2015 at 17:03
  • \$\begingroup\$ @nikoliazekter The question is about using custom content in a game made with Monogame. I don't think your comment is relative here \$\endgroup\$
    – dimitris93
    Commented May 5, 2015 at 17:37

1 Answer 1


I recommend creating a custom Content project for each unique format. I recommend this blog as a starting point: http://dylanwilson.net/creating-custom-content-importers-for-the-monogame-pipeline Also take a look at the answer to this question: MonoGame 3.4 Content Pipeline Extension missing reference

A custom Content project will enable you to create your own .xnb format files. A custom Content project makes using your unique file formats equally simple as using out-of-the-box supported formats such as .png and .mp3 .

In your list of requirements you state that an external program needs the files as well. If this is because the external program is a tool you use to create/modify these assets, then it is no problem. Simply point the Content project to the source file and the Content pipeline will convert it to a .xnb content file when you build your project.

If you want the external program to be able to access the files when your game is already build then you really don't have another option than leave the files as-is. However I'm not sure how that would work for mobile, as I believe all mobile installs are in a container and are generally not able to access files from other packages.

TitleContainer.OpenStream() allows you to read from the filesystem. If your package includes the files, I would expect the method to be able to read it. After all, as you state, Unity would copy the content to a folder as well. So if you set the properties of the files to be included in your build step, you should be able to read it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .