[change] 直接配置了每个unity大版本对应的hybridclr及il2cpp_plus版本,避免出现安装了不兼容版本的问题
parent
dbd8121ee2
commit
bf6ae99dad
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"versions": [
|
||||||
|
{
|
||||||
|
"unity_version":"2019",
|
||||||
|
"hybridclr" : { "branch":"main", "hash":"531f98365eebce5d1390175be2b41c41e217d918"},
|
||||||
|
"il2cpp_plus": { "branch":"2019-main", "hash":"ebe5190b0404d1857832bd1d52ebec7c3730a01d"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unity_version":"2020",
|
||||||
|
"hybridclr" : { "branch":"main", "hash":"531f98365eebce5d1390175be2b41c41e217d918"},
|
||||||
|
"il2cpp_plus": { "branch":"2020-main", "hash":"c6cf54285381d0b03a58126e0d39b6e4d11937b7"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unity_version":"2021",
|
||||||
|
"hybridclr" : { "branch":"main", "hash":"531f98365eebce5d1390175be2b41c41e217d918"},
|
||||||
|
"il2cpp_plus": { "branch":"2021-main", "hash":"99cd1cbbfc1f637460379e81c9a7776cd3e662ad"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -20,24 +20,60 @@ namespace HybridCLR.Editor.Installer
|
||||||
Ok,
|
Ok,
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class InstallerController
|
|
||||||
|
|
||||||
|
|
||||||
|
public class InstallerController
|
||||||
{
|
{
|
||||||
private const string hybridclr_repo_path = "hybridclr_repo";
|
private const string hybridclr_repo_path = "hybridclr_repo";
|
||||||
|
|
||||||
private const string il2cpp_plus_repo_path = "il2cpp_plus_repo";
|
private const string il2cpp_plus_repo_path = "il2cpp_plus_repo";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int MajorVersion => _curVersion.major;
|
public int MajorVersion => _curVersion.major;
|
||||||
|
|
||||||
private UnityVersion _curVersion;
|
private readonly UnityVersion _curVersion;
|
||||||
|
|
||||||
|
private readonly HybridclrVersionManifest _versionManifest;
|
||||||
|
private readonly HybridclrVersionInfo _curDefaultVersion;
|
||||||
|
|
||||||
public InstallerController()
|
public InstallerController()
|
||||||
{
|
{
|
||||||
_curVersion = ParseUnityVersion(Application.unityVersion);
|
_curVersion = ParseUnityVersion(Application.unityVersion);
|
||||||
|
_versionManifest = GetHybridCLRVersionManifest();
|
||||||
|
_curDefaultVersion = _versionManifest.versions.Find(v => v.unity_version == _curVersion.major.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UnityVersion
|
private HybridclrVersionManifest GetHybridCLRVersionManifest()
|
||||||
|
{
|
||||||
|
string versionFile = $"{SettingsUtil.ProjectDir}/{SettingsUtil.HybridCLRDataPathInPackage}/hybridclr_version.json";
|
||||||
|
return JsonUtility.FromJson<HybridclrVersionManifest>(File.ReadAllText(versionFile, Encoding.UTF8));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
class VersionDesc
|
||||||
|
{
|
||||||
|
public string branch;
|
||||||
|
|
||||||
|
public string hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
class HybridclrVersionInfo
|
||||||
|
{
|
||||||
|
public string unity_version;
|
||||||
|
|
||||||
|
public VersionDesc hybridclr;
|
||||||
|
|
||||||
|
public VersionDesc il2cpp_plus;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
class HybridclrVersionManifest
|
||||||
|
{
|
||||||
|
public List<HybridclrVersionInfo> versions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnityVersion
|
||||||
{
|
{
|
||||||
public int major;
|
public int major;
|
||||||
public int minor1;
|
public int minor1;
|
||||||
|
@ -120,75 +156,22 @@ namespace HybridCLR.Editor.Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _hybridclrLocalVersion;
|
public string HybridclrLocalVersion => _curDefaultVersion.hybridclr.hash;
|
||||||
|
|
||||||
public string HybridclrLocalVersion => _hybridclrLocalVersion != null ? _hybridclrLocalVersion : _hybridclrLocalVersion = GetHybridCLRLocalVersion();
|
public string Il2cppPlusLocalVersion => _curDefaultVersion.il2cpp_plus.hash;
|
||||||
|
|
||||||
|
|
||||||
public string HybridCLRRepoInstalledVersion
|
|
||||||
{
|
|
||||||
get { return EditorPrefs.GetString($"hybridclr_repo#{MajorVersion}"); }
|
|
||||||
set { EditorPrefs.SetString($"hybridclr_repo#{MajorVersion}", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Il2CppRepoInstalledVersion
|
|
||||||
{
|
|
||||||
get { return EditorPrefs.GetString($"il2cpp_plus_repo#{MajorVersion}"); }
|
|
||||||
set { EditorPrefs.SetString($"il2cpp_plus_repo#{MajorVersion}", value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private string GetHybridCLRLocalVersion()
|
|
||||||
{
|
|
||||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
|
||||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
|
||||||
if (Directory.Exists(hybridclrRepoDir))
|
|
||||||
{
|
|
||||||
var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
|
||||||
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
|
||||||
false);
|
|
||||||
if (ret.ExitCode == 0)
|
|
||||||
{
|
|
||||||
return ret.StdOut.Trim();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "ERROR";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private string _il2cppPlusLocalVersion;
|
|
||||||
|
|
||||||
public string Il2cppPlusLocalVersion => _il2cppPlusLocalVersion != null ? _il2cppPlusLocalVersion : _il2cppPlusLocalVersion = GetIl2cppPlusLocalVersion();
|
|
||||||
|
|
||||||
private string GetIl2cppPlusLocalVersion()
|
|
||||||
{
|
|
||||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
|
||||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
|
||||||
if (Directory.Exists(il2cppPlusRepoDir))
|
|
||||||
{
|
|
||||||
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
|
||||||
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
|
||||||
false);
|
|
||||||
if (ret.ExitCode == 0)
|
|
||||||
{
|
|
||||||
return ret.StdOut.Trim();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "ERROR";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetIl2CppPathByContentPath(string contentPath)
|
private string GetIl2CppPathByContentPath(string contentPath)
|
||||||
{
|
{
|
||||||
return $"{contentPath}/il2cpp";
|
return $"{contentPath}/il2cpp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void InstallDefaultHybridCLR()
|
||||||
|
{
|
||||||
|
InstallLocalHybridCLR(HybridclrLocalVersion, Il2cppPlusLocalVersion);
|
||||||
|
}
|
||||||
|
|
||||||
public void InstallLocalHybridCLR(string hybridclrVer, string il2cppPlusVer)
|
public void InstallLocalHybridCLR(string hybridclrVer, string il2cppPlusVer)
|
||||||
{
|
{
|
||||||
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), _curVersion, hybridclrVer, il2cppPlusVer);
|
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), _curVersion, hybridclrVer, il2cppPlusVer);
|
||||||
|
@ -218,8 +201,20 @@ namespace HybridCLR.Editor.Installer
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CloneSpeicificCommitId(string workDir, string repoUrl, string branch, string repoDir, string commitId)
|
||||||
|
{
|
||||||
|
BashUtil.RemoveDir(repoDir);
|
||||||
|
BashUtil.RunCommand(workDir, "git", new string[] {"clone", "-b", branch, repoUrl, repoDir});
|
||||||
|
BashUtil.RunCommand($"{repoDir}", "git", new string[] { "checkout", commitId });
|
||||||
|
}
|
||||||
|
|
||||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, UnityVersion version, string hybridclrVer, string il2cppPlusVer)
|
private void RunInitLocalIl2CppData(string editorIl2cppPath, UnityVersion version, string hybridclrVer, string il2cppPlusVer)
|
||||||
{
|
{
|
||||||
|
if (!IsComaptibleVersion())
|
||||||
|
{
|
||||||
|
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||||
Directory.CreateDirectory(workDir);
|
Directory.CreateDirectory(workDir);
|
||||||
//BashUtil.RecreateDir(workDir);
|
//BashUtil.RecreateDir(workDir);
|
||||||
|
@ -231,44 +226,12 @@ namespace HybridCLR.Editor.Installer
|
||||||
// clone hybridclr
|
// clone hybridclr
|
||||||
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
||||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||||
{
|
CloneSpeicificCommitId(workDir, hybridclrRepoURL, _curDefaultVersion.hybridclr.branch, hybridclrRepoDir, hybridclrVer);
|
||||||
BashUtil.RemoveDir(hybridclrRepoDir);
|
|
||||||
string[] args = new string[]
|
|
||||||
{
|
|
||||||
"clone",
|
|
||||||
"--depth=1",
|
|
||||||
"-b",
|
|
||||||
hybridclrVer,
|
|
||||||
hybridclrRepoURL,
|
|
||||||
hybridclrRepoDir,
|
|
||||||
};
|
|
||||||
var ret = BashUtil.RunCommand(workDir, "git", args);
|
|
||||||
//if (ret != 0)
|
|
||||||
//{
|
|
||||||
// throw new Exception($"git clone 失败");
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clone il2cpp_plus
|
// clone il2cpp_plus
|
||||||
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
||||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||||
{
|
CloneSpeicificCommitId(workDir, il2cppPlusRepoURL, _curDefaultVersion.il2cpp_plus.branch, il2cppPlusRepoDir, il2cppPlusVer);
|
||||||
BashUtil.RemoveDir(il2cppPlusRepoDir);
|
|
||||||
string[] args = new string[]
|
|
||||||
{
|
|
||||||
"clone",
|
|
||||||
"--depth=1",
|
|
||||||
"-b",
|
|
||||||
il2cppPlusVer,
|
|
||||||
il2cppPlusRepoURL,
|
|
||||||
il2cppPlusRepoDir,
|
|
||||||
};
|
|
||||||
var ret = BashUtil.RunCommand(workDir, "git", args);
|
|
||||||
//if (ret != 0)
|
|
||||||
//{
|
|
||||||
// throw new Exception($"git clone 失败");
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create LocalIl2Cpp
|
// create LocalIl2Cpp
|
||||||
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
||||||
|
@ -303,17 +266,17 @@ namespace HybridCLR.Editor.Installer
|
||||||
Debug.LogError($"未找到当前版本:{curVersionStr} 对应的改造过的 Unity.IL2CPP.dll,打包出的程序将会崩溃");
|
Debug.LogError($"未找到当前版本:{curVersionStr} 对应的改造过的 Unity.IL2CPP.dll,打包出的程序将会崩溃");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (version.major >= 2021)
|
||||||
|
{
|
||||||
|
Debug.LogError($"如果需要打包iOS,必须手动替换UnityEditor.CoreModule.dll为修改后的版本,否则无法获得AOT dlls。详见 https://focus-creative-games.github.io/hybridclr/modify_unity_dll/#unityeditor-coremodule-dll");
|
||||||
|
}
|
||||||
if (HasInstalledHybridCLR())
|
if (HasInstalledHybridCLR())
|
||||||
{
|
{
|
||||||
Debug.Log("安装成功!");
|
Debug.Log("安装成功");
|
||||||
_hybridclrLocalVersion = null;
|
|
||||||
_il2cppPlusLocalVersion = null;
|
|
||||||
HybridCLRRepoInstalledVersion = hybridclrVer;
|
|
||||||
Il2CppRepoInstalledVersion = il2cppPlusVer;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("安装失败!");
|
Debug.LogError("安装失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,9 @@ namespace HybridCLR.Editor.Installer
|
||||||
{
|
{
|
||||||
private InstallerController _controller;
|
private InstallerController _controller;
|
||||||
|
|
||||||
string _hybridclrVersion;
|
|
||||||
string _il2cppPlusVersion;
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_controller = new InstallerController();
|
_controller = new InstallerController();
|
||||||
_hybridclrVersion = _controller.HybridCLRRepoInstalledVersion;
|
|
||||||
if (string.IsNullOrWhiteSpace(_hybridclrVersion))
|
|
||||||
{
|
|
||||||
_hybridclrVersion = "main";
|
|
||||||
}
|
|
||||||
_il2cppPlusVersion = _controller.Il2CppRepoInstalledVersion;
|
|
||||||
if (string.IsNullOrWhiteSpace(_il2cppPlusVersion))
|
|
||||||
{
|
|
||||||
_il2cppPlusVersion = $"{_controller.MajorVersion}-main";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
|
@ -44,34 +31,33 @@ namespace HybridCLR.Editor.Installer
|
||||||
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
|
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasInstall = _controller.HasInstalledHybridCLR();
|
||||||
|
|
||||||
GUILayout.Space(10f);
|
GUILayout.Space(10f);
|
||||||
|
|
||||||
EditorGUILayout.BeginVertical("box");
|
EditorGUILayout.BeginVertical("box");
|
||||||
bool hasInstall = _controller.HasInstalledHybridCLR();
|
|
||||||
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
||||||
|
GUILayout.Space(10f);
|
||||||
|
|
||||||
if (hasInstall)
|
EditorGUILayout.LabelField($"HybridCLR 版本: {_controller.HybridclrLocalVersion}");
|
||||||
{
|
GUILayout.Space(5f);
|
||||||
EditorGUILayout.LabelField($"HybridCLR 版本: {_controller.HybridclrLocalVersion}");
|
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
||||||
GUILayout.Space(5f);
|
GUILayout.Space(5f);
|
||||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
||||||
GUILayout.Space(5f);
|
//GUILayout.Space(40f);
|
||||||
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
|
||||||
//GUILayout.Space(40f);
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.Space(10f);
|
GUILayout.Space(10f);
|
||||||
|
|
||||||
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
//EditorGUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或branch或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
|
//EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或branch或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
|
||||||
_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
|
//_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
|
||||||
EditorGUILayout.EndHorizontal();
|
//EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
//EditorGUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或branch或tag)(默认取{_controller.MajorVersion}-main分支最新版本):", GUILayout.MaxWidth(400));
|
//EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或branch或tag)(默认取{_controller.MajorVersion}-main分支最新版本):", GUILayout.MaxWidth(400));
|
||||||
_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
|
//_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
|
||||||
EditorGUILayout.EndHorizontal();
|
//EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
|
||||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||||
|
@ -93,20 +79,7 @@ namespace HybridCLR.Editor.Installer
|
||||||
|
|
||||||
private void InstallLocalHybridCLR()
|
private void InstallLocalHybridCLR()
|
||||||
{
|
{
|
||||||
if (!_controller.IsComaptibleVersion())
|
_controller.InstallDefaultHybridCLR();
|
||||||
{
|
|
||||||
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrWhiteSpace(_hybridclrVersion))
|
|
||||||
{
|
|
||||||
_hybridclrVersion = "main";
|
|
||||||
}
|
|
||||||
if (string.IsNullOrWhiteSpace(_il2cppPlusVersion))
|
|
||||||
{
|
|
||||||
_il2cppPlusVersion = $"{_controller.MajorVersion}-main";
|
|
||||||
}
|
|
||||||
_controller.InstallLocalHybridCLR(_hybridclrVersion, _il2cppPlusVersion);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.focus-creative-games.hybridclr_unity",
|
"name": "com.focus-creative-games.hybridclr_unity",
|
||||||
"version": "1.1.19",
|
"version": "1.1.20",
|
||||||
"displayName": "HybridCLR",
|
"displayName": "HybridCLR",
|
||||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||||
"category": "Runtime",
|
"category": "Runtime",
|
||||||
|
|
Loading…
Reference in New Issue