spöokyjon ℵ 18617 Posts user info edit post |
I'm trying to work through the XNA tutorial on using XML files with the content pipeline, but I keep running into trouble. All I'm getting is a relatively blank XML file:
<?xml version="1.0" encoding="utf-8"?> <XnaContent> <Asset Type="BlockPipeline.BlockPipelineContent" /> </XnaContent>
After debuggin/stepping though code, I've found that the custom writer method is never actually called, which would explain why the custom class writing never shows up in the XML. My problem is that the tutorial doesn't really explain the link between the custom ContentTypeWriter.Write() function and what goes on in the main part of the code.
Okay, with these two code snippets here:
This is the main function of the program; this stuff always runs
using System.Xml; using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
namespace BlockPipeline { class TempMain { public static void Main() { BlockPipelineContent testBlock = new BlockPipelineContent(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true;
using (XmlWriter xmlWriter = XmlWriter.Create("testSettings.xml", settings)) { IntermediateSerializer.Serialize(xmlWriter, testBlock, null); } } } }
and this part SHOULD be called, but it never is:
using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler; using Microsoft.Xna.Framework.Graphics;
namespace BlockPipeline { [ContentTypeWriter] class BlockSettingsWriter : ContentTypeWriter { protected override void Write(ContentWriter output, BlockPipelineContent value) { output.Write(value.getPosition()); output.Write(value.getMySpriteString()); output.Write(value.isSolid()); output.Write(value.getZ()); }
public override string GetRuntimeType(TargetPlatform targetPlatform) { return "Extinctathon.Block, Extinctathon"; }
public override string GetRuntimeReader(TargetPlatform targetPlatform) { return "Extinctathon.BlockReader, Extinctathon"; } }
}
I'm getting these XML files without anything custom written to them. Any suggestions?
Oh, and of course when this issue comes up creators.xna.com is down.]5/20/2008 10:53:10 AM |
Rat Suspended 5724 Posts user info edit post |
um n/m. hold up. let me have a look
[Edited on May 20, 2008 at 11:01 AM. Reason : .] 5/20/2008 11:00:23 AM |
Rat Suspended 5724 Posts user info edit post |
I'm not familiar with:
[ContentTypeWriter] class BlockSettingsWriter : ContentTypeWriter
I typically use-> XmlDocument and add -> XmlNode nodes to it.
just add an xml file to your content or a folder somewhere and pass it that location and add/subtract from it as you with using those classes 5/20/2008 11:18:00 AM |
qntmfred retired 40726 Posts user info edit post |
i'm not familiar with XNA
but looking at the code, i don't see why the BlockSettingsWriter Write method would be called. your Main() doesn't use a BlockSettingsWriter object
[Edited on May 20, 2008 at 12:45 PM. Reason : per the this part SHOULD be called comment] 5/20/2008 12:45:08 PM |
spöokyjon ℵ 18617 Posts user info edit post |
Yeah...like I said, I don't at this point understand the actual flow of the program. However, this is the method that is given in Microsoft's XNA tutorials, but of course that whole site is down at the moment.
HRM. 5/20/2008 12:51:32 PM |
spöokyjon ℵ 18617 Posts user info edit post |
lulz, they totally revamped/relaunched the XNA site totay and as far as I can tell the tutorial I was working from is no longer a part of the site 5/20/2008 3:45:01 PM |
tsavla All American 6787 Posts user info edit post |
5/20/2008 3:55:12 PM |
spöokyjon ℵ 18617 Posts user info edit post |
For anybody who cares to know, for some reason, although the tutorial I was using tells you how to write the ContentTypeWriter, it apparently doesn't really use it (or something).
Any public members of the class will be written to the XML file. I changed the neccessary members to public and that now works. Going to XNA forums for the rest 5/20/2008 5:03:47 PM |
spöokyjon ℵ 18617 Posts user info edit post |
Also, FWIW, the purpose of using the custom ContentTypeWriter/Reader is so that you can add XML files to your project which are converted to XMB (i.e. binary XML files) at compile time for teh speed boosts and whatnot. 5/20/2008 6:52:32 PM |