Open 3D Engine Atom Gem API Reference
23.05.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
#include <AssetCollectionAsyncLoader.h>
Inherits MultiHandler.
Classes | |
struct | AssetToLoadInfo |
Public Types | |
using | OnAssetReadyCallback = AZStd::function< void(AZStd::string_view, bool, size_t)> |
The user must provide this type of callback when calling LoadAssetsAsync(...) | |
Public Member Functions | |
AZ_DISABLE_COPY_MOVE (AssetCollectionAsyncLoader) | |
bool | LoadAssetsAsync (const AZStd::vector< AssetToLoadInfo > &assetList, OnAssetReadyCallback onAssetReadyCB) |
template<class AssetClass > | |
Data::Asset< AssetClass > | GetAsset (AZStd::string_view assetPath) const |
Should be called after onAssetsReadyCB was fired at least once. | |
void | Cancel () |
Static Public Attributes | |
static constexpr char | AssetCollectionAsyncLoaderName [] = "AssetCollectionAsyncLoader" |
Friends | |
class | AssetDiscoveryJob |
Accepts a list of assets to load. Notifies (On Main Thread) with a callback once all assets have been loaded. REMARK 1: This class goes beyond simply calling GetAssetIdByPath, because it accepts a list of Asset Products that may not exist at all. For this reason it spawns a job that will call GetAssetIdByPath until it returns a valid Data::Asset<> for all requested asset products. There's a possibility one of the assets may never exist, and the job could run forever, it is up to the caller to cancel the job because it is taking too long. IN AN IDEAL scenario this class could query with AzToolsFramework API whenever the AssetProcessor is finished processing all assets and if one of the requested assets never became valid the job could auto finish with an error to the user, BUT we can not use the AzToolsFramework. REMARK 2: An asset can still be valid but may have errors. This case is handled properly and the user of this API will be notified whenever there are such errors.
void AZ::AssetCollectionAsyncLoader::Cancel | ( | ) |
Cancel any pending asset loading jobs, etc. If no job is pending this function does nothing.
bool AZ::AssetCollectionAsyncLoader::LoadAssetsAsync | ( | const AZStd::vector< AssetToLoadInfo > & | assetList, |
OnAssetReadyCallback | onAssetReadyCB | ||
) |
Returns true if the list of assets were successfully enqueued for loading. Returns false if there were jobs pending or the input list was empty. Called on Main Thread. As each asset is loaded this callback is triggered. When "pendingAssetCount" reaches zero the user knows all assets have been loaded.