UniTask icon indicating copy to clipboard operation
UniTask copied to clipboard

Add AsyncInstantiate support

Open ilakhin opened this issue 1 year ago • 9 comments

https://docs.unity3d.com/2023.3/Documentation/ScriptReference/AsyncInstantiateOperation_1.html

ilakhin avatar Feb 17 '24 21:02 ilakhin

What is UNITASK_ASYNCINSTANTIATE_SUPPORT?

neuecc avatar Feb 19 '24 05:02 neuecc

AsyncInstantiateOperation was added since Unity 2022.3.20 / 2023.3.0b7:

  • https://unity.com/releases/editor/whats-new/2022.3.20
  • https://unity.com/releases/editor/beta

I didn't find a define like UNITY_2022_3_20_OR_NEWER to restrict the methods.

ilakhin avatar Feb 19 '24 08:02 ilakhin

Unity doesn't add new APIs in patch versions. It was added in 2022.3.0, so you can use UNITY_2022_3_OR_NEWER.

https://docs.unity3d.com/2023.3/Documentation/ScriptReference/AsyncInstantiateOperation_1.html

timcassell avatar Feb 19 '24 12:02 timcassell

Unity 2022.3.19f1 does not support this API. It was added in a patch version (https://unity.com/releases/editor/whats-new/2022.3.20). image

ilakhin avatar Feb 19 '24 14:02 ilakhin

Oh I missed it in the notes because of the weird formatting. Player: Added: Object.InstantiateAsync<T>().... Ugh, Unity doing stupid things so much.

timcassell avatar Feb 19 '24 14:02 timcassell

There is a new define in 2022.3.20f1 that can be used instead of #if UNITASK_ASYNCINSTANTIATE_SUPPORT: #if UNITY_2022_3_20

I assume it's supposed to be #if UNITY_2022_3_20_OR_NEWER, but we'll know for sure once 2022.3.21f1 comes out.

Torgo13 avatar Mar 04 '24 08:03 Torgo13

I've come up with the following define. It's not elegant but it does what you want.

// 2022.3.20f1 or newer
#if UNITY_2022_3_OR_NEWER && !(UNITY_2022_3_0 || UNITY_2022_3_1 || UNITY_2022_3_2 || UNITY_2022_3_3 || UNITY_2022_3_4 || UNITY_2022_3_5 || UNITY_2022_3_6 || UNITY_2022_3_7 || UNITY_2022_3_8 || UNITY_2022_3_9 || UNITY_2022_3_10 || UNITY_2022_3_11 || UNITY_2022_3_12 || UNITY_2022_3_13 || UNITY_2022_3_14 || UNITY_2022_3_15 || UNITY_2022_3_16 || UNITY_2022_3_17 || UNITY_2022_3_18 || UNITY_2022_3_19)

nansofting avatar Mar 05 '24 15:03 nansofting

is there any progress? we need it

xtutu avatar May 16 '24 02:05 xtutu

What's the expected behaviour when the extensions introduced in this PR are used with an AsyncInstantiateOperation with the allowSceneActivation flag set to false? From what I have understood looking at the code the task would never complete.

Thordreck avatar Jun 11 '24 07:06 Thordreck