ドキュメント

Unity Engine

Unity Engine

AddRequest

Represents an asynchronous request to add a package to the project.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

public sealed class AddRequest : Request<PackageInfo>, ISerializationCallbackReceiver

Remarks

The PackageManager Client class returns an AddRequest instance when you call the Client.Add method to add a package to your project. Use this object to determine when the request is complete and to access the result.
Once the request comsplete, you can retrieve the PackageInfo instance from the Result property.
using UnityEngine;using UnityEditor.PackageManager;using UnityEditor.PackageManager.Requests;[ExecuteInEditMode]public class PackageManagerAddExample : MonoBehaviour{ AddRequest m_AddRequest; void Start() { Debug.Log("Client.Add example..."); m_AddRequest = Client.Add("com.unity.textmeshpro"); } void Update() { if (m_AddRequest != null && m_AddRequest.IsCompleted) { if (m_AddRequest.Status == StatusCode.Success) { var package = m_AddRequest.Result; Debug.Log($"Added package: {package.name}" + $"\nVersion: {package.version}" + $"\nDisplay name: {package.displayName}"); } else { Debug.LogError($"Add failed: {m_AddRequest.Error.message}"); } m_AddRequest = null; } }}
Related information

Inheritance