Search Unity

Cannot instantiate assetreference in code

Discussion in 'Addressables' started by yonson_chappers, Jan 27, 2021.

  1. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    33
    really struggling with this issue with addressables.

    I have some prefabs. set them to 'addressable'. I have them in the default local group / no special settings. Using standard code to instantiate them, and its been working fine for months (no updates etc).

    Now all of a sudden all asset references are coming back as null exceptions, have tried both asset references (below) and as a string. Have checked every possible setting including deleting the entire Library and rebuilding from scratch, still nothing. Can anyone please help with what has gone wrong?

    I thought the whole point of Addressables was that it was meant to make object instantiation easier, this is all just baffling, I can grab the prefab, load it into my scene but the addressables system refuses to find it.

    Thank you for your help!


    Code (CSharp):
    1.     public AssetReference a;
    2.  
    3.     // Start is called before the first frame update
    4.     void Start()
    5.     {
    6.         Addressables.InstantiateAsync(a).Completed += e =>
    7.         {
    8.  
    9.             GameObject item = e.Result;
    10.             if (item != null)
    11.             {
    12.                 Debug.Break();
    13.             }
    14.  
    15.         };
    16.     }
    upload_2021-1-27_23-55-33.png
     

    Attached Files:

  2. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    184
    Did you update your addressables? I've been crying over my code over the last few days after updating to Addressables 1.16.16. Similar code to you, just returning null all over the place.

    Same code used to work for months and months.

    I finally figured out the problem was with the update, and downgraded to 1.16.15. Works again now.

    I also tried spending 7 hours making a repro project for 1.16.16, but I can't get it to break in my mini repro project. I'm going insane.

    I'm going to stick with 1.16.15 for a while, it seems.
     
  3. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    33
    Hi
    thank you - actually its the opposite, I was using the latest verified version of addressables, so updated it to the absolute latest version (1.16.16) today and its started working again. Whats bizarre though is that it was working fine before anyway, it just randomly decided to make everything null.

    It seems incredibly ironic that a system like Addressables which is mean to make management of assets easier / more reliable is actually achieving the complete opposite, adding new layers of complexity and confusion than there was before. Incredibly frustrating

    Glad you got your issues sorted;)