Skip to content

rds1983/XNAssets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

107 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XNAssets

NuGet Chat

XNAssets is the asset management library for Monogame/FNA. Unlike Content Pipeline, it loads raw assets.

Adding Reference

XNAssets consists of following assemblies(click on the name for MonoGame nuget link):

Name Description
XNAssets Base assets types(textures, effects, etc)
XNAssets.FontStashSharp FontStashSharp support

See this on how to reference the library in the FNA project.

Outputing assets loading logging to console

AMBConfiguration.Logger = Console.WriteLine;

Creating AssetManager

Creating AssetManager that loads files:

AssetManager assetManager = AssetManager.CreateFileAssetManager(@"c:\MyGame\Assets");

Creating AssetManager that loads resources:

AssetManager assetManager = AssetManager.CreateResourceAssetManager(_assembly, "Resources");

If _assembly's name is "Assembly.Name" then the above code will create AssetManager that loads resources with prefix "Assembly.Name.Prefix.".

If we don't the assembly's name prepended to the prefix, then pass 'false' as the third param when calling CreateResourceAssetManager. I.e.

AssetManager assetManager = AssetManager.CreateResourceAssetManager(_assembly, "Full.Path.Resources", false);

Loading Assets

After AssetManager is created, it could be used following way to load SpriteFont:

    SpriteFont font = assetManager.LoadSpriteFont(graphicsDevice, "fonts/arial64.fnt");

Or following way to load Texture2D:

    Texture2D texture = assetManager.LoadTexture2D(graphicsDevice, "images/LogoOnly_64px.png");

Base XNAssets allows to load following asset types:

Type Method Name Description
Texture2D LoadTexture2D Texture in BMP, TGA, PNG, JPG, GIF, PSD or DDS format. There's optional parameter that determines whether the alpha should be premultiplied. The parameter is ignored if loading dds.
TextureCube LoadTextureCube Cube Texture in DDS format.
SpriteFont LoadSpriteFont Font in AngelCode's BMFont .fnt format
SoundEffect LoadSoundEffect SoundEffect in WAV format
Effect LoadEffect Effect in binary form

FontStashSharp Support

After referencing XNAssets.FontStashSharp, it would be possible to load FontSystem through following code:

FontSystem fs = assetManager.LoadFontSystem("arial.ttf");

Or StaticSpriteFont through:

StaticSpriteFont ssf = assetManager.LoadStaticSpriteFont(graphicsDevice, "arial.fnt");

Loading 3D Models

DigitalRiseModel is library that allows to load 3d models from GLTF/GLB through XNAssets.

Additional Documentation

See AssetManagementBase documentation if you want to learn more(i.e. how to add additional loader methods).

About

Alternative to MonoGame Content Pipeline that loads raw assets.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages