[ Web Proxy ]
URL:
Viewing: https://docs.unity3d.com/ScriptReference/PackageManager.Requests.AddRequest.html [Back]  [Original]

Unity - Scripting API: AddRequest
Version: Unity 6.5 (6000.5)
    • Supported
    • Legacy
    LanguageEnglish
    • C#

    AddRequest

    class in UnityEditor.PackageManager.Requests

    /

    Inherits from:PackageManager.Requests.Request_1

    Suggest a change

    Success!

    Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

    Close

    Submission failed

    For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

    Close
    Your name Your email Suggestion* Submit suggestion

    Cancel

    Switch to Manual

    Description

    Represents an asynchronous request to add a package to the project.

    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; } } }

    Inherited Members

    Properties

    PropertyDescription
    ErrorThe error returned by the request, if any.
    IsCompletedWhether the request is complete.
    StatusThe request status.
    ResultA property that provides access to the result of a completed Package Manager request operation.

    Web Proxy Viewer  |  New URL  |  Original Page