Closed IAFahim closed 3 weeks ago
Yeah it's a great API, I tested it a while back, it's a testament to the async era. You can now use it as an optimization technique for generating heavy objects without having to worry too much about when they're generated like dynamically loading maps...
Yaa, using it in prewarm pool will be really effective and of course it also comes with RequestAsync
Of course you had checked it before 🥲 and I thought I have a new information. But I don't understand how you could have known about it because its only available on unity 6.1
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Object.InstantiateAsync.html
And about RequestAsync it's there on the documents on unity site(I might not know how to look that good)
No, It was added since unity 2022.3.20
Ehh bad unity website documentation design.
Thank you Sir for your guidance. You always know a lot, and helpful.
I just tried brenchmarking between Instantiate
and InstantiateAsync
but maybe this visual explanation is too obvious here. And there is no problem if calling Request
or Return
while PrewarmAsync
is not completed
public GameObject prefab;
private void Start()
{
prefab.PrewarmAsync(10, 10).Forget();
}
Thank you for explanation, Sir.
public GameObject prefab; private void Start() { prefab.PrewarmAsync(10, 10).Forget(); }
Isn't the second parameters in PrewarmAsync a CancellationToken
in this repo. Are a you trying out a new method?
The prewarm method previously available for IAsyncObjectPool
with the existing async implementations will be no different, the new Prewarm method added for SharedGameObjectPool
and GameObjectPool
which implements the utility APIs for GameObject
Maybe I'll add CancellationToken to it too
I just found out from here: https://github.com/keijiro/InstantiateAsyncTest?tab=readme-ov-file
Prewarm for pooling can become really powerful.