Search Unity

Addressables - How to force wait until completed

Discussion in 'Addressables' started by douglassophies, Jun 26, 2020.

  1. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    I have seen the discussion threads on asyc vs sync design paths and I don't really want to rehash that debate.
    But there must be a way to freeze the program while the asset finishes loading. I am not even worried if the program becomes unresponsive I just need a couple ms longer.

    This is not my use case but an example might be handling the case where a player with a slow connection immediately runs to the very end of a maze before the assets have loaded in so you have to flash open a temporary loading screen for a few seconds while the game catches up.
    Is the only way to do something like that, a manually coded pause? You could not throw up a splash screen then have the program effectively freeze with a simple API call or neat bit of code?
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    If you have your game running based on Time.deltaTime, you could set the timescale to 0 to pause everything.
    Otherwise, like you expect, you would have to handle all that manually.
     
    douglassophies likes this.
  3. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    141
    Ah that is lame. But thanks for the confirmation.
     
  4. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Actually I don't find it lame, it is very much preferred way to handle the situation you described (with a loading screen). Sync loading has it's uses but it's not good for your case. How would you implement loading indication UI animations if your game main thread freezes completely? Pausing the gameplay w/o blocking the main thread is the best approach for this IMO.