Download

Import dialog

I’m trying to figure out if there’s a way to summon a file browser type dialog that I can use to import assets with custom import options. I’ve tried:


unreal.AssetTools.import_assets_with_dialog('/Game/tmp')

…but I get the following error:


Error: TypeError: descriptor 'import_assets_with_dialog' requires a 'AssetTools' object but received a 'str'

From the UE Python documentation for AssetTools:

So I’m confused… The documentation seems to clearly state that destination_path needs to be a string. So why is Unreal complaining that it should be an AssetTools object?

import_assets_with_dialog is a method, so you need to call it on an instance rather than the type. The error is trying to say that the ‘self’ argument was the wrong type.


asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
asset_tools.import_assets_with_dialog('/Game/tmp')

Great, that worked. It seems that I need to get better at understanding Python error messages. The fact that the error complained about an object and not a parameter was probably a good hint that the part that was wrong wasn’t the bit inside the brackets.

Thank you Jamie.