Search Unity

How to get components of a newly loaded addressable asset?

Discussion in 'Addressables' started by k3ndro, Aug 29, 2019.

  1. k3ndro

    k3ndro

    Joined:
    Dec 8, 2016
    Posts:
    28
    Code (CSharp):
    1.     private void LocationLoaded(AsyncOperationHandle<IList<IResourceLocation>> obj)
    2.     {
    3.         Debug.Log("Callback triggered. Loading done!");
    4.  
    5.         remoteNos = new List<IResourceLocation>(obj.Result);
    6.  
    7.         // how to convert remoteNos[0] to a gameobject? my goal is just to access its components
    8.  
    9.     }
    How to convert remoteNos[0] to a gameobject? my goal is just to access its components
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    You've loaded the location, just do another round async operation to get the game object.

    Addressables.InstantiateAsync<GameObject>(remoteNos[0])
     
    k3ndro and unity_bill like this.
  3. k3ndro

    k3ndro

    Joined:
    Dec 8, 2016
    Posts:
    28
    Thanks