Importing Asset Metadata with UE4.20
4.20 is proving to be a really cool release, so here’s yet another great addition: Asset Metadata.
Users can now add any kind of data (strings, numbers, etc.) directly in their DCC tool and export it into Unreal Engine.
The official documentation only shows how to do that in 3ds max and Maya, I’m not sure if it can be done with other programs/exporters at this stage.
Let’s see how to do that in both Autodesk’s softwares.
In Maya, select any mesh you want to export and add some data with Modify → Add Attribute:
In the new windows that opens, just add a name for our new Attribute.
You can also set the Data Type value (String, in this example), but be aware that this would just be valid inside of Maya; once exported in Unreal Engine, all the Metadata attributes will be converted into a string.
Make sure the attribute was correctly added to your object. You can check into the Attribute Editor (inside the Extra Attributes section):
Don’t forget to add a value to My String attribute and press Enter to confirm.
Now you can export the mesh as usual (FBX format only!) and import into Unreal Engine.
You can add new Metadata attributes from the Object Properties window. Right-click on the mesh you want to export and select Object Properties. Switch to the User Defined tab and add a couple attributes like shown below. Click OK to confirm.
Things are slightly different in 3ds max, so be aware that all the Metadata attributes you add here will be put together into a single string in Unreal Engine 4, so you’ll need to split the string yourself (in Blueprints or Python, whatever you’ll be using).
Unreal Engine 4
You don’t need to take any further steps inside the UE4 FBX Importer window in order to import the new Metadata attributes, it will just flow along with the imported mesh data.
To check that everything went fine, you can right-click on your asset in the Content Browser and select Asset Actions → Show Metadata:
As you can see, we got a couple attributes (Note: the picture refers to the mesh exported from Maya, not 3ds max).
Our attribute is FBX.TestString (attribute name, or key) and MyAwesomeTag (attribute value).
Being able to import Metadata along with assets opens to a whole lot of new possibilities. For example, you can use it to filter assets in the Content Browser (see an example here).
If you want to read this data via Blueprints, you can for example create a new Blutility deriving from ActorActionUtility or AssetActionUtility (have a look at this tutorial for more information), and then use the nodes Get Metadata Tag or Get Metadata Tag Values:
Don’t forget to use the full Metadata tag (in the previous example, it’s FBX.TestString, while in Maya it was simply called TestString).