public string error ;

描述

如果下载期间出错,则返回错误消息(只读)。

如果未出现错误,error 将返回 null 或空字符串(因为某些平台不允许字符串值为 null 值)。我们建议您使用 String.IsNullOrEmpty 检查是否存在错误,以便涵盖这两种情况。

如果对象尚未下载完数据,将一直处于阻塞状态,直到下载完成。 使用 isDoneyield 查看数据是否可用。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { // Make a request with an invalid url public string url = "invalid_url"; IEnumerator Start() { using (WWW www = new WWW(url)) { yield return www; if (!string.IsNullOrEmpty(www.error)) Debug.Log(www.error); } } }

示例中的 URL 是无效的,因此错误消息将是“Couldn't resolve host”。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961