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.

Question AssetReference in ScriptableObject that is always loaded(Preloaded assets in PlayerSettings)

Discussion in 'Addressables' started by Tudamun, Feb 27, 2023.

  1. Tudamun

    Tudamun

    Joined:
    Sep 20, 2022
    Posts:
    7
    Is it possible that addressable assets that are serialized as AssetReference in a preloaded ScriptableObject are always loaded into memory?

    I am unable to find this information anywhere, if someone could point me to the correct location I would very much appreciate it.

    I've tried with profiler and memory profiler, however the references they show do not provide anything tangible.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,968
    That looks like the Memory Profiler Module that's a part of the Profiler Windows, and not the Memory Profiler Package. The latter might be more helpful for checking the references. You can take snapshots or import them into the 1.0 version of the package from within an empty 2022.2 project.

    Also, is this an Editor capture, or from a built Player?
     
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    4,492
    You will need to load them into memory yourself.

    Last I remember though, the point at which pre-loaded assets are loaded into memory is too early for the addressables system to be called. It's best to manually load them in with a boot-strap scene (you'll need one using addressables anyway).

    That's how I work it anyway.
     
  4. Tudamun

    Tudamun

    Joined:
    Sep 20, 2022
    Posts:
    7
    I don't want to preload them. I am trying to figure out what is causing them to be loaded into memory without manually loading them. I cannot find any useful reference info from profiler.
     
  5. Tudamun

    Tudamun

    Joined:
    Sep 20, 2022
    Posts:
    7
    I've tried also with memory profiler package but nothing helpful was shown as to what is holding/loading the assets into memory.

    Also it was an editor capture.
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,968
    We know of some ways in which we could make the References table clearer in future versions, but do you have any examples of how it was failing to help you? Did you check the "Status" shown in the Details section?

    Also, unless you are trying to improve the memory usage in the Editor, it's really advisable to take snapshot from development build on the device. The Editor can do some odd things memory wise to ensure everything works smoothly that might muddy the waters when you try to analyze it, and Addressables are especially susceptible to that.
     
  7. Tudamun

    Tudamun

    Joined:
    Sep 20, 2022
    Posts:
    7
    Thanks Martin, will do that in the following week. But just for information sake: Would an AssetReference in a ScriptableObject that is included in the PreloadedAssets in PlayerSettings cause the addressable asset to be loaded into memory?
     
  8. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    4,492
    No I don't believe it would. I haven't experienced this at least.

    Most likely some editor-specific behaviour is at play here.
     
    MartinTilo likes this.