|
|
@@ -41,6 +41,7 @@ public class CEntity_Base : ScriptableObject
|
|
|
public string CardID = "";
|
|
|
public int MaxCountInDeck = 4;
|
|
|
public bool HasLoadStarted { get; set; } = false;
|
|
|
+ public Task CurrentLoadingTask { get; set; } = null;
|
|
|
public Sprite CardSprite { get; set; } = null;
|
|
|
public async Task LoadCardImage()
|
|
|
{
|
|
|
@@ -59,13 +60,20 @@ public class CEntity_Base : ScriptableObject
|
|
|
Sprite sprite = await StreamingAssetsUtility.GetSprite(CardSpriteName, isCard: true);
|
|
|
|
|
|
CardSprite = sprite;
|
|
|
+
|
|
|
+ CurrentLoadingTask = null;
|
|
|
}
|
|
|
|
|
|
public async Task<Sprite> GetCardSprite()
|
|
|
{
|
|
|
if (!HasLoadStarted)
|
|
|
{
|
|
|
- await LoadCardImage();
|
|
|
+ CurrentLoadingTask = LoadCardImage();
|
|
|
+ await CurrentLoadingTask;
|
|
|
+ }
|
|
|
+ else if (CurrentLoadingTask != null)
|
|
|
+ {
|
|
|
+ CurrentLoadingTask?.Wait();
|
|
|
}
|
|
|
|
|
|
return CardSprite;
|