Last night I was having a dabble with XNA’s content pipeline, trying to figure out how to create my own content processors. In the end I went through the whole process of importing an asset from file, processing the asset, writing it out to a .xnb (binary format) and then finally reading it back from a .xnb.
To sum that up, all of that except the reading is controlled by the Content project and it is done as an offline preprocessor step. The reading of the .xnb is the only part of the pipeline that happens at runtime. The way that it is done is quite neat too as none of the pre-processing code will end up in the final build’s code base due to it (and the Content project) being excluded from inclusion.
When I first got it working I couldn’t really see the point of it as it would have been easy to write one function in my code base that would read the file from whatever format I wanted it to. However, I can now see that it provides a nice, clean way to preprocess assets (for any number of reasons). It removes the need for a collection of other tools and consolidates them in a single place.
Aside from the content processors, I was hoping to find a way to make XNA let me keep my assets elsewhere (dropbox in this case) instead of the Content project folder. Previously I’ve had no other reason to store them elsewhere but now I do, version control (kind of). To add an asset to a XNA Content project, makes a copy of the asset in the Content projects folder. I was thinking I would have hack something in but it turns out is incredibly easy to do it. When you’re adding the asset, instead of clicking “Add” in the open dialog window you just click the drop down button and select “Add as link”. I reckon you can guess what it does by the name.