Setting Metadata

How to set metadata on an Unreal Asset

Setting Metadata

Assets in the Content Browser can have metadata added to them using Python, to do this we just need a loaded reference to the asset (unreal.load_asset()). With a loaded asset reference we can use the EditorAssetLibrary to apply our metadata:

asset_path = "/Game/some/asset/path"
asset = unreal.load_asset(asset_path)

unreal.EditorAssetLibrary.set_metadata_tag(asset, "key", "value")

Note: Metadata is stored as strings, make sure any numbers or other data types are converted to a string for this function

Because of how regularly I make use of metadata in my Unreal tools, even though it's small I do use a convenience function for this command to convert the value's type to a string for me:

def set_metadata(asset, key, value):
    """set the asset's metadata value"""
    unreal.EditorAssetLibrary.set_metadata_tag(asset, key, str(value))

Last updated