Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Addressable asset has a null reference when instantiated via LoadAssetAsync

Discussion in 'Addressables' started by dgoyette, May 16, 2019.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I'm wondering if anyone has seen this behavior. I have fairly simple prefab, which has a component on it that references a Scriptable Object asset ("the config"). If I drag this prefab into my scene, it works fine, and I see that "the config" is on the object. However, when I instantiate the object dynamically, then the component has a null reference to the config.

    I'm loading the object via Addressables.LoadAssetAsync, following by calling Instantiate on the result.

    My understanding was that Addressibles was smart enough to include dependencies, and that I won't need to mark every possible dependency as Addressable and put it in a category. That said, "the config" shows up in the "Duplicate Asset Isolation" section of the addressables window:

    upload_2019-5-16_19-7-46.png

    Has anyone seen this behavior before?

    I tried manually adding "the config" to the same group as the object I'm spawning, and that "fixes" the issue. Now the reference isn't null. But again, I thought that Addressables should automatically find dependencies, and I don't need to manually add every possible dependency to Addressables for it to work.
     
  2. onesharkdevelopers

    onesharkdevelopers

    Joined:
    Jun 27, 2019
    Posts:
    5
    I think we have to do the same thing you did. our build is crashing due to adding Addressable assets - to lighten load on memory. It has Null Ref right away when we try to Addressables.InstantiateAsync.

    I'll see if I can follow your workaround here and find that config.
     
  3. onesharkdevelopers

    onesharkdevelopers

    Joined:
    Jun 27, 2019
    Posts:
    5
    Thanks for your post - it led me to understand why I had a problem. I was loading a large addressable asset to avoid memory problem and didn't include its dependencies like you mentioned. I had to remove it because it's clearly not a good candidate for addressables compare to other simple objects.
     
  4. OVProducts

    OVProducts

    Joined:
    May 30, 2017
    Posts:
    2