2 Commits
Author SHA1 Message Date
cneicy 7096459763 fix(installer): complete context bundle roots
Publish UPM package / publish (push) Successful in 2s
2026-08-26 13:22:01 +08:00
cneicy c42d24bcde fix(installer): refresh package state after resolution
Publish UPM package / publish (push) Successful in 2s
2026-08-26 13:01:52 +08:00
5 changed files with 63 additions and 5 deletions
@@ -36,6 +36,12 @@ public static class ShrinkInstallerDevelopmentValidation
?.GetValue(null) as IEnumerable;
Require(Count(packages) == 20, "包目录数量不是 20。");
Require(Count(bundles) == 8, "推荐组合数量不是 8。");
Require(BundleContainsInstallRoot(bundles, "基础应用(推荐)",
"com.cneicy.shrink-context-eventbus-adapter"),
"基础应用组合没有显式安装 Context 事件适配。");
Require(BundleContainsInstallRoot(bundles, "常用完整套件",
"com.cneicy.shrink-context-eventbus-adapter"),
"常用完整套件没有显式安装 Context 事件适配。");
}
finally
{
@@ -60,6 +66,32 @@ public static class ShrinkInstallerDevelopmentValidation
return count;
}
private static bool BundleContainsInstallRoot(IEnumerable bundles, string bundleName, string packageName)
{
foreach (var bundle in bundles)
{
var bundleType = bundle.GetType();
if (!string.Equals(bundleType.GetProperty("DisplayName")?.GetValue(bundle) as string, bundleName,
StringComparison.Ordinal))
continue;
var roots = bundleType.GetProperty("InstallRoots")?.GetValue(bundle) as IEnumerable;
if (roots == null)
return false;
foreach (var root in roots)
{
var value = root.GetType().GetProperty("PackageName")?.GetValue(root) as string;
if (string.Equals(value, packageName, StringComparison.Ordinal))
return true;
}
return false;
}
return false;
}
private static Type FindType(string fullName) => AppDomain.CurrentDomain.GetAssemblies()
.Select(assembly => assembly.GetType(fullName, false))
.FirstOrDefault(type => type != null)
+27 -1
View File
@@ -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();
+2 -2
View File
@@ -153,7 +153,7 @@ namespace ShrinkSDK.Installer
DataSaverApp, DataSaverEventBus, NetworkApp, NetworkEventBus,
StarterBasic
},
new[] { StarterBasic },
new[] { StarterBasic, ContextEventBusAdapter },
recommended: true),
new ShrinkSdkPackageBundle(
"Context 最小基座",
@@ -195,7 +195,7 @@ namespace ShrinkSDK.Installer
DataSaverApp, DataSaverEventBus, NetworkApp, NetworkEventBus,
StarterBasic
},
new[] { StarterBasic, ModFramework, Tutorial })
new[] { StarterBasic, ContextEventBusAdapter, ModFramework, Tutorial })
};
internal static IReadOnlyList<ShrinkSdkPackageEntry> DistinctInstallRoots(
+1 -1
View File
@@ -15,5 +15,5 @@
## 引导地址
```text
https://git.crash.work/ShrinkSDK/Installer.git#v0.2.0
https://git.crash.work/ShrinkSDK/Installer.git#v0.2.2
```
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "com.cneicy.shrink-installer",
"version": "0.2.0",
"version": "0.2.2",
"displayName": "ShrinkSDK 包管理",
"description": "基于 UI Toolkit 的 ShrinkSDK 固定版本包管理器,提供安装状态、Context 分层与推荐组合。",
"unity": "2022.3",