Alex Stevens Profile picture
@MilkyEngineer@mastodon.gamedev.place Software Engineer/Co-Founder @TheOrphanage_au #VRDev; #UEDev Prev: Evangelist @EpicGames, Engineer @BondiLabs

Apr 28, 2020, 17 tweets

Don't know what #UE4's Asset Registry is? Wondering how to query asset data _without_ the cost of loading that asset?! Well, look no further, time for a #UETips tweetorial!

The Asset Registry caches metadata about assets under the hood of UE, and can be used to query this metadata without loading assets.
The editor uses it for gathering references, data validation, the content browser's advanced search syntax (linked), etc.
docs.unrealengine.com/en-US/Engine/C…

However, the Asset Registry can be used at runtime! When your game is cooked, asset registry data is serialised with your packages; when a package is mounted, the asset registry will load that data.

In fact, Robo Recall uses the asset registry to query packaged mods!

So how do we use it? We could query the entire asset registry for Static Meshes like so:

Or only our game's content folder:

Or maybe we received an array of asset data, and we need to filter assets in that?

"Sure Alex, but how is this useful?"
I'm glad you asked!

Well, remember when I mentioned that the registry stores metadata? You can generally see this when you hover over an asset in the content browser. For example, a Static Mesh:

We could then query that metadata using the asset registry, get the tag value (i.e. Triangles), and then filter based on that condition. If this asset satisfies a condition, we could then asynchronously load it!

The same API is used in C++, but we can also do a batch async load using the asset manager.

(The C++ API can also filter assets by tags, and optionally, their exact values. Check out FARFilter::TagsAndValues)

We could also get a list of all of the assets that this asset depends on:

Or, the opposite... find assets that depend on our asset!

For programmers, IAssetRegistry also contains a number of events that are useful, like OnPathAdded/Removed, OnAssetAdded/Removed/Updated/Renamed, etc.

Additionally, programmers can define their own tags for their assets by adding the AssetRegistrySearchable property specifier, or by overriding UObject::GetAssetRegistryTags

Python also has exposure to the asset registry:

Using the asset registry can greatly speed up the querying of assets (instead of loading them), for both the editor and your game!

If you want more information, definitely check out the docs:

- Blueprint:
docs.unrealengine.com/en-US/Blueprin…

- C++:
docs.unrealengine.com/en-US/Programm…

- Python:
docs.unrealengine.com/en-US/PythonAP…

Also, if you haven't checked it out yet, definitely take a look at
@Serellan's Soft Object Refs tutorial (I used them in the async load above). Blueprints will load every hard referenced dependency and Soft Object Refs fix this!

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling