What to extend in the content pipeline

A cheat sheet listing some common content pipeline extensibility patterns

"I want to tweak my content in some way"

  • Change the format or size of my textures
  • Apply a custom effect to my models
  • Convert a texture into a heightfield mesh

Solution: implement a custom ContentProcessor, either from scratch or by deriving from one of the built-in ones.

"I want to attach custom data to my content"

  • Store a collision skin along with my model
  • Store animation data along with my model

Solution: implement a custom ContentProcessor, deriving from one of
the built-in ones. Override the Process method, and after you chain to
the base class implementation, store your custom information in the Tag
property of the output object.

If your custom data is not already a supported pipeline type, you
will also need to implement a ContentTypeWriter and ContentTypeReader
for it. I'll blog more about that sometime soon.

"I want to add a new content pipeline output type"

  • The built-in Model class doesn't support everything I need, so I want to implement my own replacement.

Solution: implement a custom ContentProcessor, ContentTypeWriter, and ContentTypeReader.

"I want to support a new input file format"

  • For some crazy reason I'm using Deluxe Paint on the Amiga to draw
    my textures, so I want to be able to import them from Amiga .lbm files.

Solution: implement a custom ContentImporter.

"I want to read game data from XML files"

  • Mission descriptions
  • AI or physics settings
  • Configuration data for a particle system

Solution: wrap your XML data in <XnaContent> and <Asset>
tags. Add the XML file to C# Express, go to the properties for this
file and set "XNA Framework Content" to true, then choose the "XML
Content Importer" and "No Processing Required". Finally, implement a
ContentTypeWriter and ContentTypeReader for your custom type.

"I want to use fractals to compute the ultimate meaning of life"

Yeah, me too...

Comments (4)

  1. psvensson82 says:

    I’m a newbie to the XNA platform and there’s something I don’t understand. Are all assets compiled in the assembly? Isn’t there a way to add content dynamicly from files? If I want the player to be able to add an own model to my game, will he have to add it to my visual studio project and recompile it?

  2. WillemDuminy says:

    These how-to lists are very helpful, thanks!

    A minor change to the XML read item:  It is not required to implement a ContentTypeWriter; only a ContentTypeReader is needed, and you need a Type attribute to your Asset XML element.  

  3. As I wrote the other day, I’d like to help out people that are having trouble understanding the content

  4. I want to: "…attach custom data to my content", but Texture2DContent has no Tag property 🙁

Skip to main content