Getting data from any API using UnityWebRequest with UniTask

Опубликовано: 07 Октябрь 2024
на канале: NotJustUnity
1,339
28

UniTask: https://github.com/Cysharp/UniTask
Reqres: https://reqres.in/
Flash: https://github.com/siwalikm/Flash

UniTask is a powerful library for handling asynchronous operations in Unity. With UniTask, you can write clean and efficient code for your games that is easy to read and maintain. In this tutorial, we'll cover the basics of UniTask and show you how to use it in your Unity projects.

The UnityWebRequest is a replacement for Unity’s original WWW object. It provides a modular system for composing HTTP requests and handling HTTP responses. The primary goal of the UnityWebRequest system is to permit Unity games to interact with modern Web backends. It also supports high-demand features such as chunked HTTP requests, streaming POST/PUT operations and full control over HTTP headers and verbs.

For end-users who only employ common WWW use cases, transitioning to the new system should be almost a find-and-replace process.

The system consists of two layers. A Low-Level API (LLAPI) provides maximum flexibility for power users, while a High-Level API (HLAPI) wraps the Low-Level API and provides a convenient interface for performing common operations.

#asyncawait #asynchronous #unity #unity3d #gamedev #UnityWebRequest#Unity #Networking #Unity #Web #API #Unity #REST #API #Unity #HTTP #requests #Unity #HTTP #communication #Unity #server #communication #Unity #server #integration