I am trying out some of the Addressables’ loading examples to instantiate gameobjects (mostly UI elements and particle effects) at run-time.
I am noticing that once my game is running after pressing play, the first call I make to LoadAssetAsync<T>(string someKey)
, or any other async load/instantiate method, freezes the game briefly for about 1-2 seconds. All calls thereafter with the same string key are instant. I am not subscribing to the Completion event or awaiting the result in any way - just the method call by itself causes this behaviour.
Is this normal? I’d like to also know if I’m misunderstanding the purpose of Addressable assets - I’m trying to use them a convenient, organized, and non thread-blocking way to instantiate prefabs on demand.
A simple example that causes this behaviour for me is:
public class MyScript : MonoBehaviour
{
void Update()
{
if (Keyboard.current.wKey.wasPressedThisFrame)
{
Addressables.LoadAssetAsync<Sprite>("someKey");
}
}
}