// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
namespace UltimateXR.Extensions.Unity.IO
{
///
/// extensions.
///
public class ResourcesExt
{
#region Public Methods
///
/// Loads a resource asynchronously.
///
/// The path relative to a Resources folder
/// Optional cancellation token, to cancel the operation
/// Resource type to load
/// Awaitable that returns the loaded resource
public static async Task Load(string filePath, CancellationToken ct = default)
where T : Object
{
ResourceRequest op = Resources.LoadAsync(filePath);
await op.Wait(ct);
return (T)op.asset;
}
#endregion
}
}