ReceiveData(byte[], int)
Callback, invoked as data is received from the remote server.
Read time 2 minutesLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Networking
- Assembly: UnityEngine.UnityWebRequestModule
protected virtual bool ReceiveData(byte[] data, int dataLength)
Parameters
Returns
Type | Description |
|---|---|
| bool | True if the download should continue, false to abort. |
Remarks
This callback is invoked on the main thread.
ReceiveDatadatadataLengthReceiveDatatruefalsefalsetrueData arriving from the remote server for a DownloadHandlerScript is kept in a temporary buffer. When there is unprocessed data in the buffer, this method is called once per frame to pass chunks of the data to the script. If multiple datagrams arrive within one frame, they are combined before being passed to this callback. The data byte array contains the received data.
When operating in non-preallocated mode, the system allocates a new byte array each time this callback is invoked. In this case, is equal to , and you can safely ignore the argument.
data.LengthdataLengthdataLengthWhen operating in preallocated mode, the data argument will be the byte array passed in at construction time, and the dataLength argument indicates which bytes in the byte array are new.
Important: The system does not zero-out the array between calls.
For more information on allocation modes, refer to the constructor description for DownloadHandlerScript.