Class Content
Provides static methods for loading content assets using the MonoGame content builder.
public static class Content
- Inheritance
-
Content
- Inherited Members
Methods
Initialize(ContentManager, string)
Initializes the static content manager.
public static void Initialize(ContentManager contentManager, string root)
Parameters
contentManagerContentManagerThe Microsoft.Xna.Framework.Content.ContentManager instance from the main Game class.
rootstringThe root directory path (typically "Content").
LoadFromRoot<T>(string, string)
Loads an asset by temporarily switching the ContentManager's root directory to a different location.
public static T LoadFromRoot<T>(string root, string path)
Parameters
rootstringThe temporary root directory to load from.
pathstringThe path to the asset within that root.
Returns
- T
Type Parameters
TThe type of asset to load.
Remarks
This restores the original root directory after loading is complete.
Load<T>(string)
Loads an asset of type T from the default content root directory.
public static T Load<T>(string path)
Parameters
pathstringThe path to the asset, relative to the content root.
Returns
- T
The loaded asset.
Type Parameters
TThe type of asset to load.