Search Unity

Can addressables be pooled or is there a benefit to that?

Discussion in 'Addressables' started by jerotas, Oct 17, 2018.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I had a customer inquire whether we could use Addressables for our Core GameKit plugin, in which currently all game objects are pooled (built in pooling solution that powers spawners and other things).

    In the keynote, I noticed that it sounds like it's still doing Instantiate and Destroy under the covers, which is typically bad/horrendous for performance, especially on mobile platforms.

    My question: is there a benefit to using a pooling solution to keep disabled copies of addressable game objects in the Hierarchy, because I believe we'd still want to have pooling regardless of using addressables or not for performance reasons.

    Initially I am thinking: not much benefit other than being able to not reference prefabs directly, which is cool. But how does actually help specifically?

    Thanks in advance!
    -Brian
     
  2. DavidLieder

    DavidLieder

    Joined:
    Feb 14, 2016
    Posts:
    84
    Aside from the pooling discussion, to answer the question from my perspective and why I would use it:

    You can quickly designate a server or CDN to download from. You can change that on the fly, for example, if the server went down or bill wasn't paid (of course all devs pay their bills on time). The initial development can be done with local assets, then the final build can be slim and all content come from a CDN. Or selected "large" file sizes could come from a CDN, etc.

    Jason Booth has a Unite talk about The Walking Dead MMO, in which case all content was coming from a CDN, and the app size was so small it was able to run as an MMO on low-end mobile devices.

    The downside would be that the player needs a WiFi to play.
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Right. I understand that it simplifies the asset bundle process. However any of the reference counting stuff would never come into play since you'd always have instantiated clones of game objects in the hierarchy even when everything is despawned...
     
  4. DavidLieder

    DavidLieder

    Joined:
    Feb 14, 2016
    Posts:
    84
    Too bad that addressables tries to be a swiss army knife. Building all the extra "features" into it really breaks it.
     
  5. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    There is a PooledInstanceProvider that is supposed to do just that. It's enabled via ResourceManagerRuntimeData.UsePooledInstanceProvider but it's marked as experimental, so I don't know how functional it is at the moment.
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks for the info. I don't touch experimental stuff.
     
  7. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    There's a lot going on in this thread, and I'm not sure I follow all of it, but I'll at least speak to the pooled provider. We wrote one and declared it experimental purely as an example. We never intend to make it non-experimental because we don't feel we can prescribe an exact pooling solution for all games. So that's there with the intent that users could take it and use it as an example for their own provider
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks Bill.
     
  9. DavidLieder

    DavidLieder

    Joined:
    Feb 14, 2016
    Posts:
    84
    @unity_bill Thanks for your response.

    Is there a way to use addressables and disable all the instantiation and create/destroy functionality, which is invasive to good development IMO? I want it to do what it's supposed to do, which is to allow the game to download on the fly and to easily specify alternate download locations. I want to be able to group addressables onto a layer that can be toggled based on criteria such as device, in-game user graphic settings, and whether WiFi is even available.

    I don't want something messing with the create/destroy or pooling issues.

    From what I understand, you seem to be saying that pooling is possible. The question that started this thread was based on whether addressables can play nice with pre-existing pooling solutions, as well as pre-existing code, without having to hijack instantiation and create/destroy, etc.
     
  10. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Pretty sure you can LoadAsset on your assets and control instantiation yourself. You just need to make sure you release the assets when you expect them to be unloaded from memory.

    Just remember to LoadAsset<GameObject>() if the item is a prefab, as the AssetBundle system does not support loading components directly from prefab assets since Unity 5.0, unlike direct prefab instantiation.
     
    DavidLieder likes this.
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks for the clarification!
     
    DavidLieder likes this.
  12. DavidLieder

    DavidLieder

    Joined:
    Feb 14, 2016
    Posts:
    84
    Thanks Alkis. Are you referring to the functionality of the new Addressables preview package? Because that's what I'm asking about. Or are you referring to a pre-existing way of doing it? Sorry for the newbie questions.
     
  13. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Both, actually! The addressables system wraps a similar API and allows you to LoadAsset as well. It just comes with exactly the same limitations, but you don’t have to use the Instantiate/ReleaseInstance pair, just LoadAsset/ReleaseAsset.
     
  14. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Thanks @AlkisFortuneFish for getting to the answer before I could (and doing so in quite a few threads on this forum!).

    you are correct that you can just load an asset, then use whatever instantiation/pooling you want from there.

    -Bill