Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Easy question(?) I must be missing something

Discussion in 'Addressables' started by Grahammmm, Aug 20, 2021.

  1. Grahammmm

    Grahammmm

    Joined:
    Jun 4, 2013
    Posts:
    12
    Hi, still getting a handle on things. As documentation suggests AssetReference.Asset should be set once the async load operation completes, but I'm not seeing that be the case. Please let me know what I have mixed up. Thank you!

    Unity 19.4.17f1
    Addressables 1.18.15
    Play Mode Script: All have same result

    Docs:
    Asset
    The loaded asset. This value is only set after the IAsyncOperation returned from LoadAsset completes. It will not be set if only Instantiate is called. It will be set to null if release is called.

    Code (CSharp):
    1. public class test : MonoBehaviour
    2. {
    3.     public AssetReference assetRef;
    4.     // Start is called before the first frame update
    5.     IEnumerator Start()
    6.     {
    7.         Debug.Log(assetRef.Asset == null); //true
    8.         var handle = Addressables.LoadAssetAsync<GameObject>(assetRef);
    9.         yield return handle;
    10.         Debug.Log(handle.Status); //Succeeded
    11.         Debug.Log(assetRef.Asset == null); //true
    12.         Debug.Log(handle.Result == null); //false
    13.  
    14.     }
    15. }
     
    Last edited: Aug 20, 2021
  2. LilMako17

    LilMako17

    Joined:
    Apr 10, 2019
    Posts:
    43
    Grahammmm likes this.