In the past I have used Content.Load<type>("filename");
all over the place. This quickly becomes a nightmare to manage and worse you start having multiple copies of the same asset loaded in several different places.
Then I moved on to using a Resources class which basically looked like the following:
public class Resources
{
public static Texture2D particle01;
...
public static Texture2D particle93;
public static Effect shader01;
...
public static Effect shader32;
public static Load(ContentManager content, GraphicsDevice device)
{ //load all the resources }
public static Unload()
{ //unload all the resources }
}
Then I could simply use Resources.particle01
to get a reference to the resource from anywhere within the same namespace.
This was a nice approach because it eliminated the duplicates that I had in the past. Also all loading was done in a single class, so it was easy to keep track of the resources. And finally, I could simply right click, for example, particle93
and click find all references to find all the places that used that texture.
However, there are issues with this approach and I would like to know if there is a better solution out there.