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

Question Nested asset refs

Discussion in 'Addressables' started by gooby429, Aug 2, 2023.

  1. gooby429

    gooby429

    Joined:
    Aug 13, 2019
    Posts:
    110
    Hello, I have a question about how nested addressables work:

    Let's say I have a script with an asset reference to an addressable scriptable object, and that SO has an Atlased sprite reference in it. So I would load the SO, then the sprite async to get the actual sprite and display it in an image or something.

    If the goal is to save memory, Is it necessary to have that nested sprite ref? Or would a direct ref to it work just the same when I release the root SO?

    I was having trouble using the profiler to test this myself, probably some editor related thing I'm not fully understanding, but that's a separate issue.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Any direct references to assets will be loaded as dependencies of an asset loaded via addressables and have their reference count increased. Same happens in reverse when unloading.

    It can be addressable if you only want to load said sprite on demand, otherwise it can be a direct to just be loaded with the SO.
     
    gooby429 likes this.
  3. Skiriki

    Skiriki

    Joined:
    Aug 30, 2013
    Posts:
    66
    In the Editor Sprite atlases and Addressables don't necessarily exhibit the same behavior in terms of their memory usage, loading and unloading patterns as they would do in a Player. So if you want to check the behavior with the Profiler, you should do so in a build.
     
    gooby429 likes this.