Note: UNet is deprecated, and will be removed from Unity in the future. A new system is under development. For more information and next steps see this blog post and the FAQ. |
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:
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
• 2017–05–16 Page amended with no editorial review