Python
Asset Doctor’s editor subsystem, TAAssetDoctorSubsystem, exposes its scan, fix and export functions to Blueprint and Python. Use them in editor scripts, Editor Utility Widgets or Editor Utility Blueprints.
Get the subsystem
Section titled “Get the subsystem”import unreal
doctor = unreal.get_editor_subsystem(unreal.TAAssetDoctorSubsystem)In Blueprint, get the editor subsystem and use the functions in the ta Asset Doctor category.
Functions
Section titled “Functions”| Python | Blueprint | Returns |
|---|---|---|
scan_paths(package_paths, show_progress=True) |
Scan Paths | Array of TAAssetDoctorIssue |
scan_project(show_progress=True) |
Scan Project | Array of TAAssetDoctorIssue |
scan_assets(assets, show_progress=True) |
Scan Assets | Array of TAAssetDoctorIssue |
apply_fixes(issues) |
Apply Fixes | Number of assets changed |
get_referencing_packages(asset_path) |
Get Referencing Packages | Array of package names |
export_report(issues, file_path) |
Export Report | True if the file was written |
find_unused_assets(package_paths) |
Find Unused Assets | TAAssetDoctorUnusedReport |
quarantine_assets(assets) |
Quarantine Assets | Batch name, empty if nothing moved |
get_quarantine_batches() |
Get Quarantine Batches | Array of TAAssetDoctorQuarantineBatch |
restore_quarantine_batch(batch_name) |
Restore Quarantine Batch | Number of assets restored |
delete_empty_folders(folders) |
Delete Empty Folders | Number of folders deleted |
make_bulk_rename_name(name, rules, index) |
Make Bulk Rename Name | The new name |
get_asset_name_error(new_name) |
Get Asset Name Error | Error text, empty when the name is valid |
bulk_rename_assets(new_names) |
Bulk Rename Assets | Number of assets renamed |
bulk_rename_actors(actors, new_labels) |
Bulk Rename Actors | Number of actors renamed |
sync_engine_asset_naming() |
Sync Engine Asset Naming | Number of asset types written, -1 before Unreal Engine 5.8 |
can_sync_engine_asset_naming() |
Can Sync Engine Asset Naming | True on Unreal Engine 5.8 and later |
The functions from find_unused_assets on were added in version 1.2.0.
scan_paths
Section titled “scan_paths”Scans every asset in the given folders and their subfolders, for example ["/Game/Props"]. Assets in Excluded Paths are skipped.
package_paths: list of package paths.show_progress: show a progress dialog with a Cancel button. The dialog only appears in the editor when more than 100 assets are scanned. If the user cancels, the issues found so far are returned.
scan_project
Section titled “scan_project”Scans the Included Paths from the settings, skipping Excluded Paths. This is what Scan project does in the panel.
scan_assets
Section titled “scan_assets”Scans a specific list of assets (unreal.AssetData). Assets in Excluded Paths are skipped.
apply_fixes
Section titled “apply_fixes”Applies every automatic fix in the list and returns the number of assets changed. Issues without an automatic fix are ignored. Unlike the panel, there is no confirmation dialog.
- Renames update references and the renamed assets are saved immediately. With Fix Up Redirectors After Rename enabled (default), the redirectors left behind are fixed up as well.
- Texture setting changes and Blueprint variable renames leave the assets unsaved. Save them yourself, for example with
unreal.EditorLoadingAndSavingUtils.save_dirty_packages. - Empty-folder fixes delete the folder, but only when it has no assets and no files.
- If several rename fixes target the same asset, only one is applied; a
Naming.Conventionrename takes priority.
get_referencing_packages
Section titled “get_referencing_packages”Returns the packages that reference the asset, according to the Asset Registry (hard and soft references), sorted by name. asset_path is a SoftObjectPath, for example an issue’s asset_path. References from C++ code, config files or string paths are not included.
export_report
Section titled “export_report”Writes the issues to a file. A .csv file name writes CSV; any other extension writes JSON. Missing folders are created. See Report formats for the fields.
Unused assets and quarantine
Section titled “Unused assets and quarantine”The same functions as the Unused tab (Unused assets), without confirmation dialogs.
find_unused_assets(package_paths)only reads. It returns aTAAssetDoctorUnusedReportwithassets(each withasset_path,asset_class,disk_sizein bytes,safe_to_quarantineandreason),empty_folders,num_assets_checked, andblocked/blocked_reasonwhen the search couldn’t run (the Asset Registry is still scanning, or a package file can’t be read).quarantine_assets(assets)moves the given assets into a new batch folder under the Quarantine Folder and returns the batch name, for example20261019_143005. Assets that are referenced now are skipped.get_quarantine_batches()lists the batches, newest first, withname,folder_path,created,num_assetsandtotal_size.restore_quarantine_batch(batch_name)moves a batch back and returns how many assets were restored.delete_empty_folders(folders)deletes the folders that have no assets and no files.
report = doctor.find_unused_assets(["/Game/Props"])if report.blocked: unreal.log_warning(report.blocked_reason)else: safe = [a.asset_path for a in report.assets if a.safe_to_quarantine] batch = doctor.quarantine_assets(safe) unreal.log("Quarantined {} asset(s) in {}".format(len(safe), batch))Bulk rename
Section titled “Bulk rename”TAAssetDoctorRenameRules holds the same fields as the Rename tab (Bulk rename): remove_from_start, remove_from_end, find, replace, use_regex, case_sensitive (Match case), case (TAAssetDoctorRenameCase.KEEP, CAPITALIZE_PARTS, PASCAL_CASE, UPPER, LOWER), prefix, suffix, number, number_start, number_step, number_digits and number_separator.
make_bulk_rename_name(name, rules, index)returns the new name for one item;indexstarts at 0 and drives the numbering.get_asset_name_error(new_name)returns why a name is invalid, or an empty text.bulk_rename_assets(new_names)takes a map of asset path to new name (in the same folder), updates references, saves and returns the count. Invalid and unchanged names are skipped.bulk_rename_actors(actors, new_labels)renames level actors in one undo step. Both lists must have the same length.
rules = unreal.TAAssetDoctorRenameRules()rules.prefix = "SM_"rules.case = unreal.TAAssetDoctorRenameCase.CAPITALIZE_PARTSrules.number = True
selected = unreal.EditorUtilityLibrary.get_selected_asset_data()new_names = {}for i, data in enumerate(selected): name = doctor.make_bulk_rename_name(str(data.asset_name), rules, i) if not str(doctor.get_asset_name_error(name)): new_names[data.to_soft_object_path()] = namedoctor.bulk_rename_assets(new_names)Sync names
Section titled “Sync names”sync_engine_asset_naming() does what the Sync names button does: it copies the naming table into Project Settings > Editor > Asset Tools > Asset Naming on Unreal Engine 5.8 and later. It returns the number of asset types written, or -1 on older engine versions. can_sync_engine_asset_naming() tells you whether it’s available.
Issue fields
Section titled “Issue fields”Each issue is a unreal.TAAssetDoctorIssue with these read-only properties:
| Property | Type | Meaning |
|---|---|---|
asset_path |
SoftObjectPath |
Object path of the asset, for example /Game/Props/Rock.Rock |
asset_class |
Name |
Class of the asset, for example StaticMesh |
rule_id |
Name |
Rule that reported the issue, for example Naming.Convention |
severity |
TAAssetDoctorSeverity |
INFO, WARNING or ERROR |
message |
Text |
Issue message |
fix_type |
TAAssetDoctorFixType |
NONE (fix by hand), RENAME or CUSTOM (the rule knows how to fix it) |
fix_data |
str |
For rename fixes, the new asset name |
referencer_count |
int |
Number of other packages that reference the asset, -1 if unknown |
Scan results are sorted by severity (errors first), then by asset path and rule id.
Examples
Section titled “Examples”Scan folders and export a report
Section titled “Scan folders and export a report”import unreal
doctor = unreal.get_editor_subsystem(unreal.TAAssetDoctorSubsystem)
issues = doctor.scan_paths(["/Game/Props", "/Game/Characters"], False)for issue in issues: print(issue.severity, issue.rule_id, issue.asset_path, issue.message)
doctor.export_report(issues, "C:/Temp/asset_doctor.json")Count errors
Section titled “Count errors”errors = [i for i in issues if i.severity == unreal.TAAssetDoctorSeverity.ERROR]unreal.log("Asset Doctor found {} error(s)".format(len(errors)))Apply only rename fixes
Section titled “Apply only rename fixes”renames = [i for i in issues if i.fix_type == unreal.TAAssetDoctorFixType.RENAME]for issue in renames: print(issue.asset_path, "->", issue.fix_data)
changed = doctor.apply_fixes(renames)unreal.log("Renamed {} asset(s)".format(changed))Fix texture settings and save
Section titled “Fix texture settings and save”texture_fixes = [ i for i in issues if str(i.rule_id).startswith("Texture.") and i.fix_type == unreal.TAAssetDoctorFixType.CUSTOM]doctor.apply_fixes(texture_fixes)
# Texture fixes leave the assets unsaved. This saves all dirty content packages.unreal.EditorLoadingAndSavingUtils.save_dirty_packages(False, True)Check the assets selected in the Content Browser
Section titled “Check the assets selected in the Content Browser”selected = unreal.EditorUtilityLibrary.get_selected_asset_data()issues = doctor.scan_assets(selected, True)List assets nobody references
Section titled “List assets nobody references”for issue in issues: if issue.referencer_count == 0: print("Possibly unused:", issue.asset_path)Only assets that have at least one issue are returned by a scan, so this lists unreferenced assets among those. For a full search that also checks config files and code, use find_unused_assets.