I tested InstantiateAsync and was surprised, that it instantiates previously loaded assets with some delay. I guess it’s because “yield return e” must delay one frame at least.

Source code:
private IEnumerator InstantiateAsyncTest()
{
float startTime = Time.time;
for (int i = 0; i < 10; i++)
{
print($"InstantiateAsync Time before {i+1}: {Time.time - startTime}");
IEnumerator e = Addressables.InstantiateAsync("FireBall");
yield return e;
}
}


You are correct, yield return must wait at least one frame. If you remove the yield, they should all instantiate at the same time.
To remove yield, I must know if current asset was loaded earlier. So if it wasn’t, I could wait for loading. Can I know that without caching loaded asset’s names by myself?
If you need to wait for one asset, then wait for many assets, Tasks should prove useful.
async Task LoadAssets(string first, params string[] rest)
{
// Await will make this async function wait until this task is done.
await Addressables.InstantiateAsync(first).Task;
Debug.Log("First asset instantiated.");
Task[] tasks = new Task[rest.Length];
for (int i = 0; i < rest.Length; ++i)
{
tasks[i] = Addressables.InstantiateAsync(rest[i]).Task;
}
// Task.WhenAll will wait for all of the tasks to complete.
await Task.WhenAll(tasks);
Debug.Log("All assets instantiated.");
}
Of course this requires you to switch to Tasks instead of coroutines. It’s also possible to do with coroutines, but much more difficult (You can only wait for one coroutine, so you would have to write your own method to wait for multiple coroutines).
Thanks. But what if I don’t want to load it all at once?
Then only load what you need. Addressables will only load what you tell it to, when you tell it to.
It’s up to you to determine how and when you do so.
Yes. But then I’ll have to wait one frame every time I load.