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.

Is there a relatively simple way to dynamically reload content files, such as effect files?

I know I can do the following:

  1. Detect change of file
  2. Run content pipeline to rebuild that specific file
  3. Unload ALL content that was loaded
  4. Load all content

And use double references to reference content files.

The problem is with step 3 (and step 2 isn't that nice either). I need to unload everything because if I have model Hero.x which references Model.fx effect, and I change the Model.fx file, I need to reload the Hero.x file which will then call LoadExternalReference on Model.fx.

Has someone managed to make this work without rewriting the whole ContentManager (and every ContentReader) and tracking calls to LoadExternalReference?

share|improve this question

2 Answers 2

I don't think this is a very common approach since the content build system is not redistributable (although some projects appear to be working around this limitation: Effect generator and XNA content compiler).

Also, here's another project that you might find interesting/useful: Content tracker. I'm not 100%, but believe it may help address some of your concerns regarding limitation 3.

share|improve this answer
    
I would use it only for development, and it could be separated to two programs, one checking and rebuiling content and other checking and reloading content. I use this in every project that is not in xna, it really simplifies shader development. –  Kikaimaru Apr 12 '12 at 8:09
up vote 0 down vote accepted

So current solution that i use is following:

I have two projects:

Continuous Pipeline

  1. Checks for changes in content pipeline project
  2. Rebuilds changed item
  3. Moves produced .xnb files to game content directory

(this approach won't work for things like .fxh and other stuff that links file in non standard way)

Game

  1. Checks for changes in game content directory
  2. Unloads all loaded assets (this is nescessary because I have my model reference effect files)
  3. Reloads all previously loaded

(Building game is set to not build content project)

What asset reference what can be found by storing ContentManager.Load calls, because thats what is called when content reader finds external reference

share|improve this answer

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.