Assets metadata and discoverability

tl;dr: How to discover and automatically load assets for preview at run-time without hardcoding their names?

I’m looking into giving XNA a new try with MonoGame, but one of the things that turned me away years ago was the complete lack of discoverability and metadata for assets, short of building one’s own content processing pipeline, I guess.

I might be looking at this the wrong way, but when I read into the documentation for ContentManager, there is no mechanism to discover the names of available assets and their metadata (type, dimensions, mips etc.).

I would be porting an editor from WinForms and GDI+, and while I’d be perfectly happy with having to use a content project and build all the assets, I have no clue how one should go about making a useful editor if you can’t let the user browse through the assets?

The reason is, assets are only loaded … when you actually load them. so there is no list whatsoever you could access - except once you already loaded it, it sits in a list to not load a ressource twice

(content.Load does just read a file which name you give as the type you provide)

but of course you could always just get all files in content folder - if you structure them so that each res type has a distinct folder you would have enough meta-information to actually build a list out of them - works equally well if you put the xnbs as an embedded ressource etc

Thanks for the quick reply. As long as the assets are always stored in separate files on the file system, then this seems to be the way to go, although it feels like a hack.
I do not understand the reason, since metadata are cheap and can be loaded on demand, just like the real asset; besides, game engines like Unreal, Unity etc. seem to take this for granted and happily load asset preview for browsing without any hand-coding.
Would the community be open to extending the content manager class for discoverability? Or how do other people solve this?

I know on windows you can load png’s without using the content builder so I just put them all in a folder and search the folder and iterate the files and load them all.

1 Like

This is how you make pipeline not suck in three easy steps:

  1. Metadata collector:
    Monofoxe/ResourceInfoMgr.cs at develop · Martenfur/Monofoxe · GitHub
    Monofoxe/ResourceInfoImporter.cs at develop · Martenfur/Monofoxe · GitHub

  2. Content hub and autoloading:
    Monofoxe/ResourceHub.cs at develop · Martenfur/Monofoxe · GitHub

  3. Pipeline addon with automated workflow:
    GitHub - Martenfur/Nopipeline: A Monogame Content Pipeline enhancer.

1 Like

Thanks for the responses so far, especially Martenfur’s open honesty :laughing:
I discovered the Nopipeline addon soon after my post, and I quickly started using it together with reiti.net’s suggestion of enumerating the file system. Will for sure take a closer look at the classes you suggest, and the Monofoxe framework.