Version: 2022.1
public void Dispose ();

描述

表示不再使用此 UnityWebRequest,并且应清理它使用的所有资源。

使用完 UnityWebRequest 对象后,无论请求成功还是失败,您都必须调用 Dispose。

安全起见,通常最好的做法是采用 using statement 确保正确清理 [UnityWebRequest],以防存在未捕获的异常。

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class MyExampleBehaviour : MonoBehaviour { public IEnumerator Start() { using (UnityWebRequest request = UnityWebRequest.Get("https://my-website.com")) { yield return request.Send(); Debug.Log("Server responded: " + request.downloadHandler.text); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961