TA logoThe Technical Artist
Home/Unreal Engine/Python in Unreal
tutorial 05
unreal engine

Python In Unreal

Workingtutorial~2 min readreviewed 2026-07-05

Editor scripting with the unreal module - batch-editing assets, walking the Asset Registry, and building your first audit script.

5.1Setup: Two Checkboxes

Enable the Python Editor Script Plugin (Edit -> Plugins -> search "Python"), restart, and you have a Python 3 interpreter inside the editor. Open Window -> Output Log and switch the console dropdown from Cmd to Python. Python in Unreal is editor-only - it automates the editor and pipeline; it doesn't run in shipped games.

5.2First Commands

Placeholder with instructions to screenshot the Unreal Python console
placeholder - python living in the output log
Python
import unreal

# who's in the level?
actors = unreal.EditorLevelLibrary.get_all_level_actors()
print(f"{len(actors)} actors in level")

# load an asset and inspect it
mesh = unreal.EditorAssetLibrary.load_asset("/Game/Meshes/SM_Rock_01")
print(mesh.get_num_lods())

# every asset path under a folder
paths = unreal.EditorAssetLibrary.list_assets("/Game/Environment", recursive=True)
print(f"{len(paths)} assets")

The API mirrors the C++ side: unreal.EditorAssetLibrary for load/save/rename/delete, unreal.EditorLevelLibrary for level actors, and typed classes (unreal.StaticMesh, unreal.Texture2D, unreal.Material) with get_editor_property() for everything else.

5.3Batch Editing - The Killer App

Python
import unreal

# Fix sRGB on every normal map under /Game (classic pipeline cleanup)
fixed = 0
for path in unreal.EditorAssetLibrary.list_assets("/Game", recursive=True):
 asset = unreal.EditorAssetLibrary.load_asset(path)
 if isinstance(asset, unreal.Texture2D) and "_N" in asset.get_name():
 if asset.get_editor_property("srgb"):
 asset.set_editor_property("srgb", False)
 unreal.EditorAssetLibrary.save_asset(path)
 fixed += 1
print(f"fixed {fixed} normal maps")
Undo and dry runs

Wrap batch edits in unreal.ScopedEditorTransaction so one Ctrl+Z reverts the whole batch - and always run a print-only dry-run pass first.

5.4The Asset Registry: Query Without Loading

Loading thousands of assets is slow. The Asset Registry answers questions from metadata without full loads:

Python
import unreal

ar = unreal.AssetRegistryHelpers.get_asset_registry()
f = unreal.ARFilter(class_paths=[unreal.TopLevelAssetPath("/Script/Engine", "StaticMesh")],
 package_paths=["/Game"], recursive_paths=True)
for data in ar.get_assets(f):
 print(data.package_name) # inspect before deciding what to load

It also exposes dependencies and referencers - the data behind the Reference Viewer - which is how audit tools count "how many things use this material?".

5.5Toward An Audit Script

At this point you have the pieces of a scene auditor: list assets, read their properties, count references, check names against a convention, and write the results to JSON with the stdlib. That is exactly what the Unreal Asset Health Dashboard companion script does. Read it as a worked example, or just run it.