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.

I am wondering if its possible to use the XNA Content Pipeline to load C# files?

I'm working on a game and am currently writing a FSM. I would like to be able to load states from the content pipeline, but the states would be written in C# and must use my interface.

Anyone know how to do this?

share|improve this question
1  
If you're going to have the classes in the content pipeline to be built with the project, why not just include them in the project directly? –  Richard Marskell - Drackir Dec 5 '11 at 16:17
add comment

2 Answers 2

It is possible to create a custom importer/processor for C# files. It's also possible to dynamically add content, although it takes a good bit of work.

Unless you really need to load in classes dynamically rather than include them in the project itself, don't do it. Your brain will thank you later.

share|improve this answer
    
Thanks guys, I think I will just include them in my project, thanks for the links I will keep them for future use. –  Iain Brown Dec 5 '11 at 16:47
add comment

XNA's standard set of importers and processors does not include anything for processing C# files specifically as content, so off-the-shelf, the content pipeline can't do what you want, unless you leave the files as unprocessed text. You can, however, extend the pipeline should you so choose.

However, doing so would probably be a waste of time. The content pipeline is intended to provide build-time transformation services to non-code assets to prepare and optimize them for use at runtime (dynamically adding content at runtime is possible, though a bit tedious, if I recall).

You're talking about executable code in your C# files, and since the content pipeline's transformation services are a build-time operation there will be no functional difference between abusing the content pipeline to hold your C# files and simply adding those same C# files to your main game project, as Drackir suggested in his comment.

In fact, even if you leave the files as unprocessed source code or write a custom content manipulation step to compile them somehow, you'd be faced with the fact that many of the APIs available to compile code, or execute compiled code, at runtime aren't available on the non-desktop platforms -- so if you intend your XNA project to run on those, you almost certainly can't use the content pipeline.

share|improve this answer
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.