UnityWebRequest provides a modular system for composing HTTP requests and handling HTTP responses. The primary goal of the UnityWebRequest system is to allow Unity games to interact with web browser back-ends. It also supports high-demand features such as chunked HTTP requests, streaming POST/PUT operations, and full control over HTTP headers and verbs.
The system consists of two layers:
To learn more about these layers, see the the following pages contained in this section:
Поддерживаемые платформы
The UnityWebRequest system supports most Unity platforms:
The UnityWebRequest ecosystem breaks down an HTTP transaction into three distinct operations:
To provide a better interface for advanced users, these operations are each governed by their own objects:
UploadHandler
object handles transmission of data to the serverDownloadHandler
object handles receipt, buffering and postprocessing of data received from the serverUnityWebRequest
object manages the other two objects, and also handles HTTP flow control. This object is where custom headers and URLs are defined, and where error and redirect information is stored.For any HTTP transaction, the normal code flow is:
Send()
call to wait for the request to complete