Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Does addressables support sequentially ordered instantiation?

Discussion in 'Addressables' started by yusufyldz318, Sep 23, 2023.

  1. yusufyldz318

    yusufyldz318

    Joined:
    Jun 20, 2022
    Posts:
    15
    Hi all,
    I have not used addressables before and I want to use it in my project. But the way I spawn my objects in my project I need to make sure that the spawn order is sequential. Meaning I use the information of the spawned object to spawn the other ones. So was thinking addressables might cause an issue if async operations are to be completed without order.
    In my case I was thinking a spawn queue and callbacks to handle all the spawning objects. Can I do that with addressables? If not, I may change the algorithm a bit depending on the answer.
     
  2. LuGus-Jan

    LuGus-Jan

    Joined:
    Oct 3, 2016
    Posts:
    165
    Addressables allows you to just load async (not instantiating) - like you would do with resources: you load a prefab, and instantiate it afterwards to get into your scene. So load them all async, keep the loading handles in a list and check for their completion. Once they're all done (and successful), start instantiating them in the desired order.
     
    Last edited: Sep 24, 2023
  3. yusufyldz318

    yusufyldz318

    Joined:
    Jun 20, 2022
    Posts:
    15
    Thank you, that was helpful. I completely forgot about it and was thinking of using InstantiateAsync method. As you said if I use LoadAssetAsync to load prefabs into memory then checking in the queue to instantiate them would definitely work.