Get Asset from Actor

Getting an Actor's asset from the Content browser

A potentially desirable Actor interaction is getting its Content Browser Asset, the source asset of the actor currently in our scene.

Frustratingly, I don't believe a magic bullet option is provided by the Unreal Python API directly that will work for any Actor type. We can still get the Content Browser Asset from just about any Actor, but we will need to make our own convenience function to achieve it.


Getting The Asset By Actor Type

There are a number of different actor classes in Unreal, each with their own method of getting the underlying asset. Here is a collection of several such functions, depending on the actor type.

But first, here is a quick snippet to get the first selected actor in the viewport:

EditorActorSubsystem = unreal.get_editor_subsystem(unreal.EditorActorSubsystem)

selection = EditorActorSubsystem.get_selected_level_actors()
actor = selection[0] if selection else None

With an actor reference, here are some of the more common code snippets to get their Content browser Asset:

Blueprint Actor

if isinstance(actor.get_class(), unreal.BlueprintGeneratedClass):
    asset_path = actor.get_class().get_outer().get_path_name()
    asset = unreal.load_asset(asset_path)

Static Mesh Actor

Skeletal Mesh Actor

Niagara Actor

Level Instances Actor

triangle-exclamation


Full Function Example

Last updated