The Asset Loader Plugin for Unreal Engine 5 provides helper functions to asynchronously load assets using TSoftObjectPtr
and TSoftClassPtr
. This plugin is designed to simplify the process of asset loading in a non-blocking manner, making it suitable for projects that require dynamic asset management.
- Asynchronous Loading: Load assets asynchronously to prevent blocking the main game thread.
- Support for TSoftObjectPtr and TSoftClassPtr: Easily load both objects and classes.
- Delegate-Based Callbacks: Pass your own delegate functions to handle the loaded assets.
- Macros: Convenient macros for simplifying the usage of the async loading functions.
- Download the Plugin: Clone or download this repository.
- Copy to Your Project: Place the
AssetLoader
plugin folder into thePlugins
directory of your Unreal Engine project. - Enable the Plugin: Open your project in Unreal Engine, navigate to the
Plugins
menu, and enable theAsset Loader Plugin
.
To load a soft object pointer asynchronously:
TSoftObjectPtr<UStaticMesh> MeshPtr = /* your asset pointer */;
LOAD_SOFT_OBJECT_POINTER_ASYNC(MeshPtr, UStaticMesh, OnMeshLoaded);
void YourClass::OnMeshLoaded(UStaticMesh* LoadedMesh)
{
if (LoadedMesh)
{
// Handle the loaded mesh
}
}
To load a soft class pointer asynchronously:
TSoftClassPtr<YourClassType> ClassPtr = /* your class pointer */;
LOAD_SOFT_CLASS_POINTER_ASYNC(ClassPtr, YourClassType, OnClassLoaded);
void YourClass::OnClassLoaded(TSubclassOf<YourClassType> LoadedClass)
{
// Handle the loaded class
}
You can also directly use the helper functions provided:
TSoftObjectPtr<USkeletalMesh> SkeletalMeshPtr = /* your skeletal mesh pointer */;
FAssetLoaderHelper::LoadAsync<USkeletalMesh>(SkeletalMeshPtr, [](USkeletalMesh* LoadedMesh)
{
if (LoadedMesh)
{
// Handle the loaded mesh
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to load Skeletal Mesh"));
}
});
The plugin logs errors and important events using the LogAssetLoader
category. Ensure your log settings are configured to capture these logs if necessary.
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes or features you'd like to add.