There are nine steps to create a custom content pipeline in Microsoft’s XNA Studio
- Add Project.
- Add Reference to Microsoft.XNA.Framework.Content.Pipeline.
- Add Namespaces.
- Specify Functionality to Override.
- Compile.
- Reference your Custom Processor from Your Game.
- Set Dependencies.
- Choose Custom Processor.
Add Project
The content pipeline will always execute when you compile the game. Regardless of the targeted platform the importer and processor will run in a Microsoft Windows environment. This means we need to create a separate project.
- Right Click on the Solution
- Click on Add
- Choose New Project
- Select Content Pipeline Extension Library
- Give it a name.
Add Reference
- Expand the new project
- Right Click on References.
- Select Microsoft.Xna.Framework.Content.Pipeline
Add Namespaces
You will want to make sure you have access to the functions you will need. Add the following using statements to the new pipeline.
} This is where you would write your custom code. Now we compile to create the assembly. You will want to use the build option or press F6. Pressing F5 will try to run the solution. Just like we added the content pipeline reference to our new pipeline we need to add a reference to our pipeline in our game. Follow the same directions in step 2. You will need to select the projects tab to see your new pipeline. Because the game project is dependant on the pipeline this is a good time to setup a dependency to the custom processor. Once you have added the texture to your Content folder you will want to choose your new processor. Right click the texture and select property. Once the properties window is open select the content processor drop down and select your new processor.
Specify Functionality to Override
In this example I will be extending the TextureProcessor. Override the Process function.
namespace CustomContentPipeline
{
[ContentProcessor(DisplayName = "CustomContentPipeline") ]
public class ExtentedTextureProcessor : TextureProcessor
{
public override TextureContent
Process(TextureContent input, ContentProcessorContext context)
{
return base.Process(input, context);
}
}Compile
Reference your Custom Processor from Your Game
Set Dependencies
Choose Custom Processor