| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using MainScripts.DCL.AssetsEmbedment.Runtime; |
| | 3 | | using System.Threading; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCL.Providers |
| | 7 | | { |
| | 8 | | public class EmbeddedAssetBundleProvider : AssetBundleWebRequestBasedProvider, IAssetBundleProvider |
| | 9 | | { |
| | 10 | | private Service<IWebRequestController> webRequestController; |
| | 11 | |
|
| | 12 | | public async UniTask<AssetBundle> GetAssetBundleAsync(string contentUrl, string hash, CancellationToken cancella |
| | 13 | | { |
| 0 | 14 | | var streamingPath = GetUrl(hash); |
| | 15 | | // For WebGL the only way to load assets from `StreamingFolder` is via `WebRequest` |
| 0 | 16 | | using var webRequest = webRequestController.Ref.GetAssetBundle(streamingPath, requestAttemps: 1, disposeOnCo |
| 0 | 17 | | return await FromWebRequestAsync(webRequest, streamingPath, cancellationToken); |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | private static string GetUrl(string hash) |
| | 21 | | { |
| | 22 | | #if UNITY_EDITOR || UNITY_STANDALONE |
| 0 | 23 | | return $"file://{Application.streamingAssetsPath}/{EmbeddedWearablesPath.VALUE}/{hash}"; |
| | 24 | | #endif |
| | 25 | | return $"{Application.streamingAssetsPath}/{EmbeddedWearablesPath.VALUE}/{hash}"; |
| | 26 | | } |
| | 27 | | } |
| | 28 | | } |