Bloom326984

I am having an issue reloading the same content. I load a Texture2D for the first time, and everything is ok. I dispose that Texture2D and load different data into the same variable, and everything is ok. I dispose the 2nd Texture2D data and reload the 1st data into the same variable, and the Texture2D.IsDisposed value is true. This happens whenever I attempt to reload a Texture2D after having disposed it earlier. I am not sure if this is expected, but it seems to me that it isn't. Any help would be appreciated.

Re: XNA Framework Reloading the same content

Jon Watte

The ContentManager does not know that the texture is disposed, so it just returns the cached pointer from the previous load. Calling Dispose directly on content that was loaded through the contentmanager is going against the design principle in XNA.

Look at ContentManager.Unload() for how to dispose all your assets when you're switching levels. (You can also Dispose() the content manager and create an entirely new instance).

Note that this means that the XNA ContentManager isn't designed for loading and un-loading data on the fly -- meaning you can't write a "streaming world" implementation using the XNA ContentManager as it is in 1.0.






Re: XNA Framework Reloading the same content

Bloom

So, am I correct in understanding that it is impossible to unload a specific resource I can only unload all resources at the same time Seems hard to imagine that such a restriction wouldn't have been addressed for release =/ Thanks again



Re: XNA Framework Reloading the same content

Jon Watte

Correct. It's not clear that that's a "limitation" per se -- it seems like a design choice. Just like the design choice that you play sound through XACT, or the design choice that you have to use an Xbox controller on PC as well.

You can implement that behavior yourself, if you need it (by de-serializing manually).





Re: XNA Framework Reloading the same content

mike_n

note that you can have multiple content managers with no problem




Re: XNA Framework Reloading the same content

Bloom

That's true, I don't know why I didn't think about using a seperate content manager for each of my streamed chunks.

As far as 'de-serializing' the content myself. Can you explain a bit more what you mean by this I am not familiar with this term.

Thanks again