In Unreal Engine, I’m using Python to call a C++ function that imports GLB files into the UEditor as UAsset resource files. However, this is an asynchronous task. How can I determine when all UAsset resource files have finished importing, so I can then notify my Python code to proceed to the next step?
This can actually be done entirely in Python if it is more convenient for you. For that, you should use the Interchange Manager API instead of the Asset Tools API. Here’s an example:
unreal.log(“After”)`In the example above, interchange_manager.import_asset() is blocking, while interchange_manager.scripted_import_asset_async() is asynchronous. The import parameters include a dynamic delegate “on_asset_done”, which can be bound to a Python callable making use of bind_callable(). Your Python function’s single parameter will receive the loaded asset object.
Alternatively, you can keep that C++ function, and use field UAssetImportTask.AsyncResults.OnDone to set a C++ callback to be executed when the import finishes. That C++ callback can then call a delegate passed into it, which your Python code can create and bind a callable to.
Please let me know if one of those solutions work for you, and feel free to ask if you need any further assistance.