Request
Base class for all Package Manager asynchronous operations. Use this class to track the status and results of package operations, such as adding, removing, or updating packages.
읽는 시간 1분최근 업데이트: 한 달 전
Definition
- Type: Class
- Namespace: UnityEditor.PackageManager.Requests
- Assembly: UnityEditor
- Implements: ISerializationCallbackReceiver
public abstract class Request : ISerializationCallbackReceiver
Remarks
- All Client (such as Client.Add, Client.Remove, and Client.List) return an object derived from the Request class.
- Check the property to know when the operation is done.
IsCompleted - Always check the property of the
Statusfor a StatusCode ofRequestbefore accessing results to make sure the operation was successful.Success
using UnityEngine;using UnityEditor.PackageManager;using UnityEditor.PackageManager.Requests;[ExecuteInEditMode]public class RequestExample : MonoBehaviour{ ListRequest m_Request; void Start() { Debug.Log("Requesting packages list..."); m_Request = Client.List(); } void Update() { if (m_Request != null && m_Request.IsCompleted) { if (m_Request.Status == StatusCode.Success) { foreach (var package in m_Request.Result) { Debug.Log($"Package: {package.name} ({package.version})"); } } else { Debug.Log($"Package list request failed: {m_Request.Error}"); } m_Request = null; } }}
Related information
Properties
Property | Description |
|---|---|
| Error | The error returned by the request, if any. |
| IsCompleted | Whether the request is complete. |
| Status | The request status. |