Search Unity

How to instantiate an gameOject by asset which we had LoadAssetAsync()?

Discussion in 'Addressables' started by wangyucheng1992, Jun 25, 2019.

  1. wangyucheng1992

    wangyucheng1992

    Joined:
    Feb 19, 2019
    Posts:
    59
    In my project, I need to loaded effect asset on game start, then sometimes to instantiate one effect by loaded asset. Now I just find Addressables.InstantiateAsync() can do it, but is it means that we have to load the effect asset again? if so ,it must be spend more time to load assect before instantiate it, In my project i thank it is not a good way, the best is to instantiate by asset which we have loaded in memory at game start. anyone have good idel to made it? thanks!
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    Options,

    1) Use AssetReference, which "cache" the asset loaded.
    2) Load asset by LoadAssetAsync, and manage asset manually (load/unload/GameObject.Instantiate)

    To eliminate allocation time, consider a spawn system, i.e. https://github.com/thefuntastic/unity-object-pool
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    note that with this method you still need to call myRef.LoadAssetAsync to get the thing in memory.