/// <summary> /// Creates an <see cref="IAsyncOperation{TResult}"/> wrapper for the Unity <see cref="AssetBundleRequest"/>. /// </summary> /// <param name="op">The source operation.</param> public static IAsyncOperation <T> ToAsync <T>(this AssetBundleRequest op) where T : UnityEngine.Object { var result = new Helpers.AssetBundleRequestResult <T>(op); result.Start(); return(result); }
/// <summary> /// Creates an asyncronous operation optimized for loading assets from an <see cref="AssetBundle"/>. /// </summary> /// <param name="assetBundle">The source <see cref="AssetBundle"/>.</param> /// <param name="assetName">Name of the prefab to load. If <see langword="null"/> the first asset of the matching type is loaded.</param> /// <param name="userState">User-defined data.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="assetBundle"/> is <see langword="null"/>.</exception> /// <returns>An operation that can be used to track the download process.</returns> public static IAsyncOperation <T> GetAssetBundleAssetAsync <T>(AssetBundle assetBundle, string assetName, object userState = null) where T : UnityEngine.Object { if (assetBundle == null) { throw new ArgumentNullException("assetBundle"); } var result = new Helpers.AssetBundleRequestResult <T>(assetBundle, assetName, userState); result.Start(); return(result); }