1
votes

I'm working on a game engine right now for a project where I'm the only programmer. Seeing as my artist and designers aren't very familiar with Visual Studio or the quirks of XNA, I'm putting together a tool for them to add animations, create levels, and the like. Most of it is fairly straightforward, of course. Standard code generation, image viewing, etc. However, I'm not sure how I'm going to add the new Texture2Ds to the project's content references.

Is there a method I can call of some sort which would take in a file location and add its reference to the XNA back-end? Or will I need to look through manually, find all the various hard-coded references, and do the work myself?

2
The XNA WinForms 2 Sample might be worth looking at. Also note the "note" in the description about having Visual Studio installed. - Andrew Russell

2 Answers

0
votes

There is no method for adding resources to your projects content references. If you wish to that you would have to edit the .csproj project file where the list of attached resources is maintained. However, this is a terribly ugly hack, so i would not advice you to do that.

The best thing to do would be to compile your resources at run-time using microsoft.xna.framework.content.pipeline. Instead of adding them to your content project.

For more information on how to compile resources at run-time with the content pipeline, see http://msdn.microsoft.com/en-us/library/bb447745%28v=XNAGameStudio.40%29.aspx

This sample shows how to do it: http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2

0
votes

You could edit the contentproj and add line(s) in the right ItemGroup like so

<Compile Include="..\Assets\**\*.png"/>
<Compile Include="..\Assets\**\*.jpg"/>

This will recursively include all files matching the descriptions into the project at build time. Note that you can add specific folders to to look in as well. For example:

<Compile Include="..\Assets\textures\*.png"/>

Will include all PNGs inside the "..\Assets\textures" directory.