Asset Path ↔ File Path
Switching between an Unreal Asset path and the Systems File path on disk
Systems File Path -> Unreal Asset Path
# The windows file path - your path goes here
file_path = "D:/projects/MyUnrealProject/Content/asset/path/demo.uasset"
# If the file path does exist in this Project, get its asset path:
asset_path = unreal.PackageTools.filename_to_package_name(file_path)
# Check if the asset path was found & exists
if asset_path and EditorAssetSubsystem.does_asset_exist(asset_path):
print(f"found valid asset: {asset_path}")Unreal Asset Path -> Systems File Path
from pathlib import Path
EditorAssetSubsystem = unreal.get_editor_subsystem(unreal.EditorAssetSubsystem)
asset_path = "/Game/some/asset/path"
# This uses pathlib.Path().resolve() to clean the file path,
# otherwise
file_path = Path(unreal.PackageTools.package_name_to_filename(asset_path)).resolve()
print(f"found valid file path: {file_path} ({file_path.exists()})")

Last updated