Ejemplo n.º 1
0
 private void OnLoadDone(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> obj)
 {
     if (obj.Status == AsyncOperationStatus.Succeeded)
     {
         GameObject prefab = obj.Result;
         GameObject.Instantiate(prefab, Vector3.right * 10.0f, Quaternion.identity);
     }
 }
    IEnumerator GetSprite()
    {
        asyncOperationSpriteHandle = Addressables.LoadAssetAsync <Sprite>("Picture_Atlas_1[ANIMAL_01]");
        //asyncOperationSpriteHandle = Addressables.LoadAssetAsync<Sprite>("Assets/_Project/Addressables/PictureTest.spriteatlas[ANIMAL_01]");

        yield return(asyncOperationHandle);

        Sprite sprite = asyncOperationSpriteHandle.Result;
    }
Ejemplo n.º 3
0
    public void TrumpCardLoaded(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> obj)
    {
        GameObject trumpCard;

        trumpCard = obj.Result;
        CardController.TrumpCards.Add(trumpCard);
        if (index == 1)
        {
            CardController.AITrumpCards.Add(trumpCard);
        }
        PlayerList.GetPlayers()[index].TrumpCards++;
        gameObject.GetComponent <TrumpCard>().AddRandomTrumpCard(trumpCard);
        trumpCard.transform.SetParent(playerPanel.GetTrumpCardPanel(index).transform, false);
    }
Ejemplo n.º 4
0
    private void LoadCompleted(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <Sprite> obj)
    {
        if (obj.Status != AsyncOperationStatus.Succeeded)
        {
            var error = "Failed to load sprite: " + m_Reference;
            if (obj.OperationException != null)
            {
                error += "\n" + obj.OperationException;
            }

            Debug.LogError(error, this);
            return;
        }

        m_UpdateSprite.Invoke(obj.Result);
    }
Ejemplo n.º 5
0
 public void OnLoadDone(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> obj)
 {
     RoundCounter++;
     gameObject.GetComponent <CardController>().DrawCard(obj.Result, RoundCounter, StartPos, endPos);
     UpdateUI();
 }
    public IEnumerator LoadSingle(string adddress, Func <GameObject, int> callback)
    {
        UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> prefabHandle = Addressables.LoadAssetAsync <GameObject>(adddress);
        yield return(prefabHandle);

        while (!prefabHandle.IsDone)
        {
            yield return(new WaitForEndOfFrame());
        }


        GameObject thing2Load = null;

        if (prefabHandle.Result != null)
        {
            thing2Load = prefabHandle.Result;
        }
        else
        {
            Debug.Log($"Failed to load {adddress}");
        }

        callback(thing2Load);
    }
    IEnumerator LoadItem(List <RuntimeItem> rItems, Func <List <RuntimeItem>, int> callback)
    {
        foreach (var rItem in rItems)
        {
            UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> prefabHandle = Addressables.LoadAssetAsync <GameObject>(rItem.Item.PrefabAddress);
            yield return(prefabHandle);

            while (!prefabHandle.IsDone)
            {
                yield return(new WaitForEndOfFrame());
            }


            if (prefabHandle.Result != null)
            {
                rItem.Prefab = prefabHandle.Result;
            }
            else
            {
                Debug.Log($"Failed to load {rItem.Item.PrefabAddress}");
            }
        }
        callback(rItems);
    }
    IEnumerator LoadItem(RuntimeItem rItem, int playerID)
    {
        UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <Sprite>     iconHandle   = Addressables.LoadAssetAsync <Sprite>(rItem.Item.IconAddress);
        UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> prefabHandle = Addressables.LoadAssetAsync <GameObject>(rItem.Item.PrefabAddress);
        yield return(iconHandle);

        yield return(prefabHandle);

        while (!prefabHandle.IsDone || !iconHandle.IsDone)
        {
            yield return(new WaitForEndOfFrame());
        }


        if (iconHandle.Result != null)
        {
            rItem.Icon = iconHandle.Result;
        }
        else
        {
            Debug.Log($"Failed to load {rItem.Item.PrefabAddress}");
        }

        if (prefabHandle.Result != null)
        {
            rItem.Prefab = prefabHandle.Result;
        }
        else
        {
            Debug.Log($"Failed to load {rItem.Item.PrefabAddress}");
        }


        _signalBus.Fire(new ItemLoadedSignal()
        {
            LoadedItem = rItem, PlayerID = playerID
        });
    }