UniTask icon indicating copy to clipboard operation
UniTask copied to clipboard

Addressables Support

Open cg-adam opened this issue 7 years ago • 11 comments

Would be great to have support for the new addressables system, so we can attach progress handlers whilst we are awaiting the downloads etc.

cg-adam avatar Nov 05 '19 12:11 cg-adam

You can refer to yKimisaki's LazyUnitask, how to use UniTaskCompletionSource to convert the loadable addressable work into a Unitask, you can see this link: https://gist.github.com/yKimisaki/5f7d2846ba21fd9bfb5358de6e5f0ed8

I also forked again and added a few extension methods: https://gist.github.com/phongsoyenmoc/211a9574a9b161a02c2fa553404c1600

aprius avatar Nov 05 '19 13:11 aprius

Thanks, i'll take a look.

cg-adam avatar Nov 05 '19 16:11 cg-adam

+1 for this request.

I created a gist to work with AsyncOperationHandles directly as the new unity Localization package returns AsyncOperationHandles when retrieving localized table entries.

https://gist.github.com/garrafote/b3bcd6a27d163382d9647032ac1a1bfa

garrafote avatar Apr 09 '20 00:04 garrafote

Currently external package can not handle by #if symbol. For this reason, please use your own extensions.

neuecc avatar Apr 15 '20 13:04 neuecc

It would be possible to support this by creating a second package that provides the AsyncOperationHandle-specific extensions. That would make it so that only users using the Addressables packages would need to pull in the addressables-specific extensions.

It would be cool to have that included in the main repository as an official part of the UniTask project, but if @neuecc doesn't want to add that to UniTask then anyone could setup a separate package that provides these extensions 😁

randomPoison avatar Apr 28 '20 21:04 randomPoison

@neuecc That's not true. Read "Version Defines" section:

https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

bdovaz avatar Apr 29 '20 08:04 bdovaz

Maybe some class with "Uncomment to enable"?

KAW0 avatar May 01 '20 22:05 KAW0

@KAW0 that won't work when using UniTask as a Unity package. For package dependencies you can't modify their contents, so uncommenting a #define to enable addressable support wouldn't be an option. Also, modifying the source code of an external dependency is generally a bad practice (hence why packages are read-only by default), so that probably wouldn't be the right solution even if it were an option.

randomPoison avatar May 01 '20 22:05 randomPoison

cant you just define a custom symbol like #if UNITASK_ADDRESSABLE_SUPPORT and let people add this to their definitions? I've seen this being used on some unity's authored packages and it works ok and there is no need for extra packages. Don't get me wrong I still like UniTask but, sorry there is no excuse other than "I dont want to" or "it's out of our scope" not to add support to these packages and have users writing their own bloated copy-and-pasty and unverified extensions.

I mean, I agree it's not the ideal case but just add a paragraph on the documentation instructing about the custom defines that need to be added for custom package support. and if people are unable to add the custom defines they can still copy and paste the contents of the class into their own project, right? what is the down side of that?

Edit: @bdovaz is right, "Version Defines" is perfect for this case.

garrafote avatar May 01 '20 23:05 garrafote

@garrafote You should absolutely make a pull request adding that functionality! It seems like @neuecc marked this as "won't fix" under the assumption that it couldn't be supported with UPM. If you provide the implementation you want, they'll probably be open to accepting it (though I could be wrong, I can't speak on their behalf).

randomPoison avatar May 02 '20 01:05 randomPoison

Thank you, I didn't know soft-references and version-defines https://blogs.unity3d.com/2019/04/16/introducing-unity-2019-1/#assembly It works fine.

I've implemented it for v2. https://github.com/Cysharp/UniTask/blob/7f61f85bc74f50d7042caf64730d2ae85f34ff20/src/UniTask/Assets/Plugins/UniTask/External/AddressableAsyncExtensions.cs The port to v1 is not currently being considered.

neuecc avatar May 05 '20 16:05 neuecc