https://github.com/Cysharp/UniTask#upm-package
GitHub - Cysharp/UniTask: Provides an efficient allocation free async/await integration for Unity.
Provides an efficient allocation free async/await integration for Unity. - GitHub - Cysharp/UniTask: Provides an efficient allocation free async/await integration for Unity.
github.com
유니티 강의를 보다가 UniTask의 존재를 알게 되었다.
기존의 async와 await와 같이 쓰던 Task와 비교해보자면 Task는 class 참조형식이지만
https://docs.microsoft.com/ko-kr/dotnet/api/system.threading.tasks.task?view=net-5.0
Task 클래스 (System.Threading.Tasks)
비동기 작업을 나타냅니다.Represents an asynchronous operation.
docs.microsoft.com
UniTask는 struct 값형식이기 때문에 힙 메모리할당을 하지 않기 때문에 CPU부하가 드는 GC의 동작을 줄여서 최적화를 하고 있다고 한다.
UniTask v2 — Zero Allocation async/await for Unity, with Asynchronous LINQ
I’ve previously published UniTask, a new async/await library for Unity, now I’ve rewritten all the code and released new one.
neuecc.medium.com
Window->PackageManager좌측의 플러스 버튼을 클릭하며 URL을 통해 패키지추가를 할 수 있다.
패키지에 UniTask가 추가된 걸 확인할 수 있다.
Addressables를 사용하는데 함수가 전부 비동기여서 유용하게 사용하였다.
Addressables.InitializeAsync().Completed += op=>
{
Addressables.Release(op);
}
위의 예제코드를 아래와 같이 사용하였다.
private async UniTask Intialize()
{
AsyncOperationHandle<IResourceLocator> initHandle = Addressables.InitializeAsync();
await initHandle;
Addressables.Release(initHandle);
}
'Unity2020.1' 카테고리의 다른 글
[Unity::Addressable]고찰 (0) | 2021.08.15 |
---|---|
[Unity::Addressable] Remote AssetBundle Update받는 방법 (0) | 2021.08.12 |
[Unity]Assets->Open C# Project 폴더가 열리는 현상 (0) | 2021.08.03 |
[Unity::Addressable] AssetBundle 빌드하기 (0) | 2021.07.20 |
[Unity] Google Login하기 (0) | 2021.07.14 |