[new] 检查当前安装的libil2cpp版本是否与package版本匹配,避免升级package后未重新install的问题

main
walon 2023-10-15 12:44:22 +08:00
parent 216d09f7b6
commit 05a34d4d12
3 changed files with 29 additions and 1 deletions

View File

@ -56,6 +56,11 @@ namespace HybridCLR.Editor.BuildProcessors
throw new BuildFailedException($"You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'");
}
if (installer.PackageVersion != installer.InstalledLibil2cppVersion)
{
throw new BuildFailedException($"You must run `HybridCLR/Installer` after upgrading package");
}
HybridCLRSettings gs = SettingsUtil.HybridCLRSettings;
if (((gs.hotUpdateAssemblies?.Length + gs.hotUpdateAssemblyDefinitions?.Length) ?? 0) == 0)
{

View File

@ -27,12 +27,15 @@ namespace HybridCLR.Editor.Installer
public string PackageVersion { get; private set; }
public string InstalledLibil2cppVersion { get; private set; }
public InstallerController()
{
_curVersion = ParseUnityVersion(Application.unityVersion);
_versionManifest = GetHybridCLRVersionManifest();
_curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => v.unity_version == _curVersion.major.ToString());
PackageVersion = LoadPackageInfo().version;
InstalledLibil2cppVersion = ReadLocalVersion();
}
private HybridclrVersionManifest GetHybridCLRVersionManifest()
@ -157,6 +160,23 @@ namespace HybridCLR.Editor.Installer
public string ApplicationIl2cppPath => GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath);
public string LocalVersionFile => $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/libil2cpp-version.txt";
private string ReadLocalVersion()
{
if (!File.Exists(LocalVersionFile))
{
return null;
}
return File.ReadAllText(LocalVersionFile, Encoding.UTF8);
}
public void WriteLocalVersion()
{
InstalledLibil2cppVersion = PackageVersion;
File.WriteAllText(LocalVersionFile, PackageVersion, Encoding.UTF8);
}
public void InstallDefaultHybridCLR()
{
InstallFromLocal(PrepareLibil2cppWithHybridclrFromGitRepo());
@ -237,6 +257,7 @@ namespace HybridCLR.Editor.Installer
if (HasInstalledHybridCLR())
{
WriteLocalVersion();
Debug.Log("Install Sucessfully");
}
else

View File

@ -46,6 +46,8 @@ namespace HybridCLR.Editor.Installer
EditorGUILayout.LabelField($"Package Version: v{_controller.PackageVersion}");
GUILayout.Space(5f);
EditorGUILayout.LabelField($"Installed libil2cpp Version: {_controller.InstalledLibil2cppVersion ?? "Unknown"}");
GUILayout.Space(5f);
GUILayout.Space(10f);