1
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Kikaimaru
    Commented Apr 12, 2012 at 8:09
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .