Game/Library/PackageCache/com.unity.package-manager-ui@2.0.13/Editor/Sources/Services/Upm/UpmSearchOperation.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2021-01-16 18:29:12 +01:00
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.PackageManager.Requests;
namespace UnityEditor.PackageManager.UI
{
internal class UpmSearchOperation : UpmBaseOperation, ISearchOperation
{
[SerializeField]
private Action<IEnumerable<PackageInfo>> _doneCallbackAction;
public void GetAllPackageAsync(Action<IEnumerable<PackageInfo>> doneCallbackAction = null, Action<Error> errorCallbackAction = null)
{
_doneCallbackAction = doneCallbackAction;
OnOperationError += errorCallbackAction;
Start();
}
protected override Request CreateRequest()
{
return Client.SearchAll();
}
protected override void ProcessData()
{
var request = CurrentRequest as SearchRequest;
var packages = new List<PackageInfo>();
foreach (var upmPackage in request.Result)
{
var packageInfos = FromUpmPackageInfo(upmPackage, false);
packages.AddRange(packageInfos);
}
_doneCallbackAction(packages);
}
}
}