Asset Path ↔ File Path
Switching between an Unreal Asset path and the Systems File path on disk
In order to get the Asset Path for a File, or a File for an Asset Path, we'll need to use the PackageTools module. There are some quirks to be aware of, but it's pretty reliable.
Systems File Path -> Unreal Asset Path
Getting the Unreal Asset path is fairly straight forward, if the resulting asset path is valid it means the asset does exist in the current Unreal Project:
Unreal Asset Path -> Systems File Path
Getting the File Path is a bit more involved, using the function as-is isn't always enough:
Note: The resulting File Path from package_name_to_filename()
might not include the extension, we'll have to take an additional step to find the valid file
If the extension is missing from the result, one option we can use is to scan the folder for any matches:
This function will:
Get the file path from the PackageTools function
If valid, return the result
otherwise, find and return the first file in the folder with our exact file name
Last updated