[new] Installer界面新增显示package版本

main
walon 2023-06-16 18:18:41 +08:00
parent c8cd323bb0
commit 0a82b0d339
2 changed files with 22 additions and 1 deletions

View File

@ -24,11 +24,14 @@ namespace HybridCLR.Editor.Installer
private readonly HybridclrVersionManifest _versionManifest; private readonly HybridclrVersionManifest _versionManifest;
private readonly HybridclrVersionInfo _curDefaultVersion; private readonly HybridclrVersionInfo _curDefaultVersion;
public string PackageVersion { get; private set; }
public InstallerController() public InstallerController()
{ {
_curVersion = ParseUnityVersion(Application.unityVersion); _curVersion = ParseUnityVersion(Application.unityVersion);
_versionManifest = GetHybridCLRVersionManifest(); _versionManifest = GetHybridCLRVersionManifest();
_curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => v.unity_version == _curVersion.major.ToString()); _curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => v.unity_version == _curVersion.major.ToString());
PackageVersion = LoadPackageInfo().version;
} }
private HybridclrVersionManifest GetHybridCLRVersionManifest() private HybridclrVersionManifest GetHybridCLRVersionManifest()
@ -37,6 +40,21 @@ namespace HybridCLR.Editor.Installer
return JsonUtility.FromJson<HybridclrVersionManifest>(File.ReadAllText(versionFile, Encoding.UTF8)); return JsonUtility.FromJson<HybridclrVersionManifest>(File.ReadAllText(versionFile, Encoding.UTF8));
} }
private PackageInfo LoadPackageInfo()
{
string packageJson = $"{SettingsUtil.ProjectDir}/Packages/{SettingsUtil.PackageName}/package.json";
return JsonUtility.FromJson<PackageInfo>(File.ReadAllText(packageJson, Encoding.UTF8));
}
[Serializable]
class PackageInfo
{
public string name;
public string version;
}
[Serializable] [Serializable]
class VersionDesc class VersionDesc
{ {

View File

@ -44,7 +44,10 @@ namespace HybridCLR.Editor.Installer
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "" : "")}", EditorStyles.boldLabel); EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "" : "")}", EditorStyles.boldLabel);
GUILayout.Space(10f); GUILayout.Space(10f);
EditorGUILayout.LabelField($"HybridCLR 版本: {_controller.HybridclrLocalVersion}");
EditorGUILayout.LabelField($"{SettingsUtil.PackageName} 版本: v{_controller.PackageVersion}");
GUILayout.Space(5f);
EditorGUILayout.LabelField($"bybridclr 版本: {_controller.HybridclrLocalVersion}");
GUILayout.Space(5f); GUILayout.Space(5f);
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}"); EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
GUILayout.Space(5f); GUILayout.Space(5f);