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 allow Unity games to interact with modern Web 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.
For end-users who only employ common WWW use cases, transitioning to the new system should be almost completely a find-and-replace process.
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.