Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AddAndRemoveRequest

Represents an asynchronous request to add package dependencies to the project, remove package dependencies from the project, or both.
Read time 1 minuteLast updated 12 days ago

Definition

public sealed class AddAndRemoveRequest : Request<PackageCollection>, ISerializationCallbackReceiver

Remarks

The PackageManager Client class returns an AddAndRemoveRequest instance when you call the Client.AddAndRemove method to add or remove package dependencies in the project. Use this object to determine when the request is complete and to access the result.
After the request completes, you can retrieve the PackageCollection instance from the Result property.
using UnityEngine;using UnityEditor.PackageManager;using UnityEditor.PackageManager.Requests;[ExecuteInEditMode]public class PackageManagerAddRemoveExample : MonoBehaviour{ AddAndRemoveRequest m_Request; void Start() { Debug.Log("Client.AddAndRemove example..."); var packagesToAdd = new[] { "com.unity.textmeshpro", "com.unity.inputsystem" }; var packagesToRemove = new[] { "com.unity.timeline" }; m_Request = Client.AddAndRemove(packagesToAdd, packagesToRemove); } void Update() { if (m_Request != null && m_Request.IsCompleted) { if (m_Request.Status == StatusCode.Success) { Debug.Log("Packages updated successfully:"); } else { Debug.LogError($"Operation failed: {m_Request.Error.message}"); } m_Request = null; } }}
Related information

Inheritance