-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathIThumbnailAttachment.cs
More file actions
67 lines (56 loc) · 2.09 KB
/
Copy pathIThumbnailAttachment.cs
File metadata and controls
67 lines (56 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using CommunicationData.URLHelpers;
using Cysharp.Threading.Tasks;
using DCL.AvatarRendering.Loading.Exceptions;
using DCL.Ipfs;
using ECS.StreamableLoading.Common.Components;
using ECS.StreamableLoading.Textures;
using System.Threading;
using UnityEngine;
namespace DCL.AvatarRendering.Loading.Components
{
/// <summary>
/// Common interface for types that can provide thumbnails.
/// Provides all necessary data and methods to create promises and wait for thumbnails.
/// </summary>
public interface IThumbnailAttachment
{
StreamableLoadingResult<SpriteData>.WithFallback? ThumbnailAssetResult { get; set; }
/// <summary>
/// Gets the thumbnail path
/// </summary>
URLPath GetThumbnail();
/// <summary>
/// Gets the URN of the attachment
/// </summary>
URN GetUrn();
/// <summary>
/// Gets the hash/ID of the attachment
/// </summary>
string GetHash();
/// <summary>
/// Gets the asset bundle manifest version
/// </summary>
AssetBundleManifestVersion? GetAssetBundleManifestVersion();
/// <summary>
/// Gets the content download URL
/// </summary>
string? GetContentDownloadUrl();
/// <summary>
/// Gets the entity ID for the promise
/// </summary>
string? GetEntityId();
/// <summary>
/// Waits for the thumbnail to be loaded
/// </summary>
async UniTask<Sprite> WaitForThumbnailAsync(int checkInterval, CancellationToken ct)
{
// This is set in ResolveAvatarAttachmentThumbnailSystem after being loaded by LoadAssetBundleSystem
do await UniTask.Delay(checkInterval, cancellationToken: ct);
while (ThumbnailAssetResult is not { IsInitialized: true });
StreamableLoadingResult<SpriteData>.WithFallback result = ThumbnailAssetResult!.Value;
if (!result.Succeeded)
throw new ThumbnailLoadFailedException();
return result.Asset;
}
}
}