| | 1 | | using DCL; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public class PlayerInfoCollectibleItem : MonoBehaviour |
| | 6 | | { |
| | 7 | | [SerializeField] private Image thumbnail; |
| | 8 | |
|
| | 9 | | internal WearableItem collectible; |
| | 10 | | private bool finishedLoading = false; |
| | 11 | |
|
| | 12 | | public void Initialize(WearableItem collectible) |
| | 13 | | { |
| 186 | 14 | | this.collectible = collectible; |
| | 15 | |
|
| 186 | 16 | | if (this.collectible == null) |
| 0 | 17 | | return; |
| | 18 | |
|
| 186 | 19 | | if (gameObject.activeInHierarchy) |
| 0 | 20 | | GetThumbnail(); |
| 186 | 21 | | } |
| | 22 | |
|
| | 23 | | private void OnEnable() |
| | 24 | | { |
| 0 | 25 | | if (collectible == null) |
| 0 | 26 | | return; |
| | 27 | |
|
| 0 | 28 | | GetThumbnail(); |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | private void GetThumbnail() |
| | 32 | | { |
| 0 | 33 | | string url = collectible.ComposeThumbnailUrl(); |
| | 34 | |
|
| | 35 | |
|
| 0 | 36 | | ThumbnailsManager.GetThumbnail(url, OnThumbnailReady); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | private void OnThumbnailReady(Asset_Texture texture) |
| | 40 | | { |
| 0 | 41 | | thumbnail.sprite = ThumbnailsManager.GetOrCreateSpriteFromTexture(texture.texture, out _); |
| | 42 | |
|
| 0 | 43 | | finishedLoading = true; |
| 0 | 44 | | } |
| | 45 | | } |