Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Await Addressables.InstantiateAsync but fail

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

  1. wangyucheng1992

    wangyucheng1992

    Joined:
    Feb 19, 2019
    Posts:
    55
    upload_2019-6-20_18-25-14.png upload_2019-6-20_18-24-45.png

    I want to use await and LoadAssetAsync or InstantiateAsync but fail,Did I write the wrong code? if so ,please show the correct code thank you!
     
    Twyker_gp likes this.
  2. Kerber996

    Kerber996

    Joined:
    Nov 9, 2016
    Posts:
    17
    Had a same issue today. AA 1.1.4 SBP 1.4.1
     
  3. zvinless

    zvinless

    Joined:
    Oct 6, 2014
    Posts:
    18
    I get this too, but can work around it by awaiting the .Task property instead of the AsyncOperationHandle directly.
     
    Twyker_gp likes this.
  4. wangyucheng1992

    wangyucheng1992

    Joined:
    Feb 19, 2019
    Posts:
    55
    thank you, I have made it !
    but i have another question:
    if i do Addressables.LoadAssetAsync("Cube") to get asset at Start(), then I want to Instantiate the Cube per 2s, so i do Addressables.LoadAssetAsync("Cube") per 2s, I want to know :
    • In the underlying code, whether the Cube Asset need to be reloaded before instantiation per time?
     
  5. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    965
    You can just call Instantiate. You are welcome to load in advance, but you don't need to, and there's definitely no reason to load more than once. Keep in mind if you do Load then Instantiate 3 times, you have to release the 3 instances, and release the load. Based on your description, you probably just want to instantiate from the get-go.