|
|
|
@@ -20,6 +20,9 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
private ListRequest? _listRequest;
|
|
|
|
|
private bool _resolvePending;
|
|
|
|
|
private double _resolveRequestedAt;
|
|
|
|
|
private bool _listRetryPending;
|
|
|
|
|
private double _nextListRetryAt;
|
|
|
|
|
private int _listRetryCount;
|
|
|
|
|
private HelpBox? _statusBox;
|
|
|
|
|
private Label? _registryState;
|
|
|
|
|
private VisualElement? _page;
|
|
|
|
@@ -71,14 +74,18 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
header.style.paddingBottom = 10f;
|
|
|
|
|
header.style.borderBottomWidth = 1f;
|
|
|
|
|
header.style.borderBottomColor = new Color(0.25f, 0.25f, 0.25f);
|
|
|
|
|
header.style.minHeight = 104f;
|
|
|
|
|
|
|
|
|
|
var title = new Label("ShrinkSDK 包管理");
|
|
|
|
|
title.style.fontSize = 20f;
|
|
|
|
|
title.style.unityFontStyleAndWeight = FontStyle.Bold;
|
|
|
|
|
title.style.height = 28f;
|
|
|
|
|
title.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
|
|
|
header.Add(title);
|
|
|
|
|
|
|
|
|
|
var description = new Label("以 Context 为组合基础,按用途安装固定版本的模块与集成包。");
|
|
|
|
|
description.style.marginTop = 4f;
|
|
|
|
|
description.style.minHeight = 20f;
|
|
|
|
|
description.style.whiteSpace = WhiteSpace.Normal;
|
|
|
|
|
header.Add(description);
|
|
|
|
|
|
|
|
|
@@ -86,6 +93,7 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
registryRow.style.flexDirection = FlexDirection.Row;
|
|
|
|
|
registryRow.style.alignItems = Align.Center;
|
|
|
|
|
registryRow.style.marginTop = 10f;
|
|
|
|
|
registryRow.style.minHeight = 22f;
|
|
|
|
|
registryRow.Add(new Label("软件源:"));
|
|
|
|
|
|
|
|
|
|
_registryState = new Label();
|
|
|
|
@@ -331,7 +339,7 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
: "已安装 " + installed.version + " · 固定 " + package.Version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsBusy => _listRequest != null || _resolvePending;
|
|
|
|
|
private bool IsBusy => _listRequest != null || _resolvePending || _listRetryPending;
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
@@ -342,6 +350,12 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
StartListRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_listRetryPending && EditorApplication.timeSinceStartup >= _nextListRetryAt)
|
|
|
|
|
{
|
|
|
|
|
_listRetryPending = false;
|
|
|
|
|
StartListRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_listRequest == null || !_listRequest.IsCompleted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@@ -349,12 +363,21 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
_listRequest = null;
|
|
|
|
|
if (list.Status == StatusCode.Success)
|
|
|
|
|
{
|
|
|
|
|
_listRetryCount = 0;
|
|
|
|
|
_installed.Clear();
|
|
|
|
|
foreach (var package in list.Result)
|
|
|
|
|
_installed[package.name] = package;
|
|
|
|
|
var count = _installed.Keys.Count(name => name.StartsWith("com.cneicy.", StringComparison.Ordinal));
|
|
|
|
|
SetStatus("状态已刷新:当前项目共解析到 " + count + " 个 ShrinkSDK 包。", HelpBoxMessageType.Info);
|
|
|
|
|
}
|
|
|
|
|
else if (string.IsNullOrWhiteSpace(list.Error?.message) && _listRetryCount < 4)
|
|
|
|
|
{
|
|
|
|
|
_listRetryCount++;
|
|
|
|
|
_listRetryPending = true;
|
|
|
|
|
_nextListRetryAt = EditorApplication.timeSinceStartup + 1d;
|
|
|
|
|
SetStatus("Unity 正在完成依赖解析,稍后自动重试安装状态(" + _listRetryCount + "/4)。",
|
|
|
|
|
HelpBoxMessageType.Info);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetStatus("读取安装状态失败:" + GetRequestError(list.Error), HelpBoxMessageType.Warning);
|
|
|
|
@@ -399,6 +422,8 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
{
|
|
|
|
|
_listRequest = null;
|
|
|
|
|
Client.Resolve();
|
|
|
|
|
_listRetryPending = false;
|
|
|
|
|
_listRetryCount = 0;
|
|
|
|
|
_resolvePending = true;
|
|
|
|
|
_resolveRequestedAt = EditorApplication.timeSinceStartup;
|
|
|
|
|
SetStatus(status, HelpBoxMessageType.Info);
|
|
|
|
@@ -409,6 +434,7 @@ namespace ShrinkSDK.Installer
|
|
|
|
|
{
|
|
|
|
|
if (IsBusy)
|
|
|
|
|
return;
|
|
|
|
|
_listRetryCount = 0;
|
|
|
|
|
StartListRequest();
|
|
|
|
|
SetStatus("正在读取当前项目的直接与间接依赖。", HelpBoxMessageType.Info);
|
|
|
|
|
RenderPage();
|
|
|
|
|