Task<Asset> GetAssetAsync()

book_4_sparkGenerated
code_blocksInput

Description

The GetAssetAsync method in the Editor.DragAssetData class is an asynchronous operation that completes when the asset is ready to use. This method is particularly useful for handling cloud assets, as it initiates the download and installation of the source package upon the first call. Subsequent calls to this method will return the same task, ensuring that the operation is not redundantly repeated.

Usage

To use the GetAssetAsync method, simply call it on an instance of Editor.DragAssetData. This method does not take any parameters and returns a Task<Editor.Asset>, which can be awaited to ensure the asset is ready before proceeding with further operations.

Example

// Example usage of GetAssetAsync
public async Task UseAssetAsync(Editor.DragAssetData dragAssetData)
{
    // Await the asset to be ready
    Editor.Asset asset = await dragAssetData.GetAssetAsync();
    
    // Use the asset as needed
    // For example, you might want to load it into the scene or perform operations on it
}