Search Unity

How does Addessables track non-gameobject assets?

Discussion in 'Addressables' started by jayatubi, Jan 14, 2019.

  1. jayatubi

    jayatubi

    Joined:
    Dec 9, 2013
    Posts:
    143
    These two interfaces `Addressables.Instantiate` and `Addressables.ReleaseIntance` would auto increases or decrease the reference count of the gameobjects. But how about the non-gameobject assets such as textures or meshes? Should I manually manage the reference count for them?
     
    JesOb and MNNoxMortem like this.
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    I'm not exactly sure what workflow you're asking about...
    1. you call Addressables.Instantiate on a texture. That doesn't make a lot of sense to me, so I'm guessing that's not it.
    2. you call Addressables.LoadAsset on a texture. Here you'd just call ReleaseAsset to unload.
    3. you call Addressables.Instantiate on a prefab that references a texture. In this case, Addressables tracks dependencies, and you can just release the prefab for things to get cleaned up properly.
     
  3. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    For us it would be
    • Add something unity agnostic to an adressable asset group (e..g *.json)
    • Add scriptable object *.asset on (This is likely covered by Adressable.LoadAsset - haven't tested it)
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    to be clear, you always pair your load/release, and with the next release we'll have a much more thorough doc covering this. Short version is Instantiate pairs with ReleaseInstance, LoadAsset pairs with ReleaseAsset.

    Just a quick note for your items... a) you don't instantiate .json, you load it, and read it (AFAIK). b) while you can instantiate a scriptable object (and pair that with a ReleaseInstance) there isn't a ton of value to doing that over just a Load/ReleaseAsset (but do it whichever way makes you happy)
     
  5. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    if you write to the ScriptableObject at runtime, using Instantiate will prevent the changes to get saved on disk / pollute version control
     
  6. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @unity_bill that was what I meant :) Just meant to include such files in a bundle.