Ok, I just went through this for the first time today. I ran into the same problem that you have and here's how I fixed it.
First, I downloaded the
Authoring-Particle-Systems-Using-XML-and-the-Content-Pipeline tutorial to see how the experts do it.
(Okay, that wasn't first. I actually tried it myself but then ran into the same error that you got.)
Next, I went through that code and then grokked the XML content technqiue. I had assumed wrong in how it worked.
Here's how I got mine to work:
I have 3 projects: GameLibrary, ContentPipeline, and Game.
I will be loading data named "PlanetSurface" that stores 3 strings (planet name, name of texture for surface, and name of texture for skydome).
Step 1: Content Pipeline coding
- In my ContentPipeline project, I created a PlanetSurfaceContentWriter and a PlanetSurfaceContent class.
- In the Content class, it's just a basic class with 3 string fields.
- In the ContentWriter class, I selected "Content Writer" when I clicked "Add New" and the template filled out almost everything to start.
- I changed the "using TWrite" code to "using TWrite=PlanetSurfaceContent" (with namespace, etc.)
- Next, I updated the output.write code and the function that stores the ContentReader class.
Step 2: Content Reader coding
- In my GameLibrary project, I created a PlanetSurfaceContentReader (using the ContentReader template) and a PlanetSurfaceData class.
- In the PlanetSurfaceData class, I copied the 3 fields from the PlanetSurfaceContentClass.
- In the Reader, I updated the "using TRead" to using PlanetSurfaceData (not content).
- In the Reader, I updated code to do the input.Read, etc. and assign my variables after creating a new instance, and then return that instance, etc.
Step 3: Game coding
- Finally, I create my XML file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="GameEngine.ContentPipeline.PlanetSurface.PlanetSurfaceMapContent">
<TerrainAssetName>Models\\Heightmaps\\DemoMap2\\heightmap</TerrainAssetName>
<SkyAssetName>Models\\Skys\\Space</SkyAssetName>
<Name>Test Planet</Name>
</Asset>
</XnaContent>
In my game, I simply use "currentSceneData = contentManager.Load<PlanetSurfaceMapData>(@"Xml\Planets\TestPlanet");"
Then it works :)
This was very hastily written, so I might do a better article later today or tonight and blog it. I had thought that it would have been a bit easier, but now I understand the difference between using this and serialization.
-----------------------------------------------
Jim Welch