Here is a script with a link to a custom package but it doesn’t want to be added to the project. What is the problem ?
using UnityEditor;
using UnityEditor.PackageManager.Requests;
using UnityEditor.PackageManager;
using UnityEngine;
namespace Unity.Editor.Example
{
[InitializeOnLoad]
static class AddLibrary
{
static AddRequest Request;
[MenuItem("Window/Add Library")]
static void Add()
{
// Add a package to the project
Request = Client.Add("file:\\C:\\Users\\111\\Desktop\\com.prorok.testpack");
EditorApplication.update += Progress;
}
static void Progress()
{
if (Request.IsCompleted)
{
if (Request.Status == StatusCode.Success)
Debug.Log("Installed: " + Request.Result.packageId);
else if (Request.Status >= StatusCode.Failure)
Debug.Log(Request.Error.message);
EditorApplication.update -= Progress;
}
}
}
}