4
\$\begingroup\$

I'm pretty new to MonoGame and XNA in general. So was wondering how I could import custom content and make it work on any platform. So I came across Content Pipeline Extensions wanted to do it like the documentation says but i cant find MonoGame.Framework.Content.Pipeline.
So I have multiple questions:

  • Where is it located?
  • Is there any other way i can load stuff like map data etc.?
  • If yes does it work on any platform?

Edit:
I can simply load files without the content pipeline. I didn't expect that to work across all platforms. Thanks to Shiro for clearing this up.

\$\endgroup\$
7
  • \$\begingroup\$ Are you trying to make a game that accepts custom content ? I don't quite understand. If you want to have content (textures, sound, etc) converted to .xnb, there is the documentation you should create a separate project from template MonoGame Content Project to convert your content. \$\endgroup\$
    – dimitris93
    Commented Sep 20, 2015 at 11:43
  • \$\begingroup\$ @Shiro I'm trying to load file formats like map files etc. Honestly just being able to load them as a String or Stream would be fine by me. Edit: also since MonoGame has it's own Pipeline now Content Projects are no longer necessary . \$\endgroup\$
    – Necro
    Commented Sep 20, 2015 at 11:49
  • \$\begingroup\$ What are map files ? Some information saved in a text file ? You don't need monogame to do that, that's already in C# core language. \$\endgroup\$
    – dimitris93
    Commented Sep 20, 2015 at 11:51
  • \$\begingroup\$ @Shiro but will it also work across all platforms? \$\endgroup\$
    – Necro
    Commented Sep 20, 2015 at 11:53
  • \$\begingroup\$ Of course it will \$\endgroup\$
    – dimitris93
    Commented Sep 20, 2015 at 11:54

2 Answers 2

8
\$\begingroup\$

The MonoGame.Extended project loads Tiled maps using a custom content importer. I wrote a tutorial about how to create custom content importers on my blog.

Of course, as @Shiro mentioned in the comments you don't need the Pipeline to load your own content with MonoGame. Just be aware that to make it work across all platforms you'll need to use TitleContainer.OpenStream. This is by far the simplest way and if it works for you by all means do it that way.

The idea of using the Pipeline is to give you the opportunity to optimize the content at compile time. You can pre-process the data and write it out as a binary XNB file to be efficiently read into the game. The process is quite involved though:

  1. Create a new project to hold your content importer, processor and writer that references the MonoGame.Framework.Content.Pipeline.dll. It's available as a NuGet package.
  2. Implement a class that derives from ContentImporter<T>
  3. Implement a class that derives from ContentProcessor<T,K>
  4. Implement a class that derives from ContentTypeWriter<K>
  5. Implement a class that derives from ContentTypeReader<K> (in the game project)
  6. Reference the DLL from the Pipeline tool (by editing your Content.mgcb file)
  7. Read the content into your game using Content.Load<K>

As you can see custom content importers can be quite daunting at first, but once you've done a few of them they are not too bad. I hope this clears some things up for you.

Finally, to answer your other question.

Where is it [MonoGame.Framework.Content.Pipeline.dll] located?

If you're not using the NuGet package for some reason, the DLL lives with the Pipeline tool in a rather obscure place. On my machine it's located here:

C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools

I found it by looking at the path set on the shortcut in the start menu.

\$\endgroup\$
3
\$\begingroup\$

the comment made by @Necr0 stating that "content projects are no longer necesary" is not entirely correct. Monogame no longer requires the XNA content project. There are still reasons to have your own content pipeline projects. You could, for example, create a content pipeline importer for your own level format. Or, if you plan to support a file format created by a tool you use (Tiled, Spine/Spriter for example). I myself made a content project that packs a bunch of images into a texture atlas, so I don't have to deal with that at runtime and I don't need to deal with that in photoshop- just save the individual files and the importer does the rest.

So, what about those references you were looking for?

If you want to make your own content projects: Reference the MonoGame.Framework.Content.Pipeline.Portable package using NuGet. The NuGet package is at the moment (sept 2015) pre-release only package. Make sure you choose Include Prerelease at the top of the Manage NuGet Packages window.

enter image description here

If you're looking to make your own content format. This excellent tutorial helped me a lot by making my own first content project: http://dylanwilson.net/creating-custom-content-importers-for-the-monogame-pipeline

\$\endgroup\$
7
  • \$\begingroup\$ beat me to it! :P \$\endgroup\$
    – Pip
    Commented Sep 20, 2015 at 12:48
  • \$\begingroup\$ :-) by 15 seconds yeehaw \$\endgroup\$
    – Felsir
    Commented Sep 20, 2015 at 12:48
  • \$\begingroup\$ Glad to see my tutorial has been helpful ;) I'd love to know what kind of importers you've been making. \$\endgroup\$ Commented Sep 20, 2015 at 12:59
  • \$\begingroup\$ I started fixing an old XNA importer for Spriter (the animation tool). I ran in a couple of issues and fixed them recreating the importer from scratch using your tutorial. Since then, I made an importer that takes an XML file as input- the XML contains paths where I store my images. The processor creates a texture atlas and writes the image and a dictionary of filenames(key) and struct of texture2D and rectangle(value) to a single contentfile. Works like a charm! Thanks for writing the blog :-) \$\endgroup\$
    – Felsir
    Commented Sep 20, 2015 at 13:07
  • 1
    \$\begingroup\$ Don't worry about refactoring yet. The first thing to do is open a discussion about what it does and how it's useful. \$\endgroup\$ Commented Sep 20, 2015 at 20:26

You must log in to answer this question.

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