timeout
The number of seconds after which UnityWebRequest attempts to abort the request if no response is received.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Property
- Namespace: UnityEngine.Networking
- Assembly: UnityEngine.UnityWebRequestModule
public int timeout { get; set; }
Remarks
The default value is which means no timeout is applied and UnityWebRequest will wait until the response is received.
0When the response takes longer than the value specified in , UnityWebRequest.error returns message.
timeoutRequest timeoutExamples
using UnityEngine;using System.Collections;using UnityEngine.Networking;// Ask the website to deliver an image that is very large.// Set the download to take more than 60 seconds. This causes// the "request timeout" error message.public class ExampleScript : MonoBehaviour{ void Start() { StartCoroutine(GetText()); } IEnumerator GetText() { using UnityWebRequest www = UnityWebRequest.Get("https://my-website.com/verylargeimage.jpg"); // Set the timeout to 60 seconds. // Abort the request if the image doesn't download within the specified timeout. www.timeout = 60; yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.LogError(www.error); } else { Debug.Log("image arrived"); } }}