Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Let's say I have an xml file which looks like this

<Weapons>
 <Weapon>
  <Name>Pistol</Name>
  ...
 </Weapon>
 <Weapon>
  <Name>MachineGun</Name>
  ...
 </Weapon>
</Weapons>

Would it be possible to use a custom importer/writer/reader to create two files, Pistol.xnb and MachineGun.xnb which I can load individually with Content.Load()?

While writing this I realized I could just import a Weapon[] list and split them up with a helper, but I'm still wondering if this is possible?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Basically: No.

The content pipeline transforms a single input file into a single output file. It can also do a single input file plus dependencies, into a single output file. And you can also trigger building of other files into assets.

But it cannot generate multiple outputs from a single file.

This thread on the App Hub forums explains it in more detail. (And may have some ideas for work-arounds.)

share|improve this answer
    
link has decayed –  Andrey Sep 4 '12 at 3:37
    
@Andrey Repaired, thanks :) –  Andrew Russell Sep 4 '12 at 4:58
add comment

Yes, you can.

With the dependency system, you can call

ContentProcessorContext.BuildAsset
ContentProcessorContext.BuildAndLoadAsset

to make the Content Pipeline build whichever asset you want, and get the external reference to that file. Keep in mind that this isn't very flexible, and all the assets built this way will have the name of the original asset plus "_0", "_1", etc. to mark them as dependent from the original.

Also, ContentProcessorContext is an abstract class and you can inherit from it and extend with the functionality you want. So, when you are compiling your specific asset, create a new instance of your custom processor context and let it do its own magic.

Keep in mind that this requires a very advanced knowledge of the XNA pipeline and will be too much effort if you are a beginner.

share|improve this answer
    
Even though this technically is a more correct answer, Andrew's was still more the answer I was looking for. –  Zeta Two Mar 28 '11 at 16:35
4  
Then if you are expecting a "no", I don't see the point in asking :) –  r2d2rigo Mar 28 '11 at 18:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.