2022-09-22 08:56:07 +08:00
|
|
|
using System;
|
2022-10-09 03:25:56 +08:00
|
|
|
using System.Reflection;
|
|
|
|
using UnityEditor;
|
2022-09-22 08:56:07 +08:00
|
|
|
using UnityEngine;
|
2022-10-09 03:25:56 +08:00
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
namespace HybridCLR.Editor.Installer
|
|
|
|
{
|
|
|
|
public class InstallerWindow : EditorWindow
|
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
private InstallerController _controller;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
2022-11-28 12:20:52 +08:00
|
|
|
string _hybridclrVersion = "";
|
|
|
|
string _il2cppPlusVersion = "";
|
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
private void OnEnable()
|
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
_controller = new InstallerController();
|
2022-09-22 08:56:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnGUI()
|
|
|
|
{
|
2022-10-09 03:25:56 +08:00
|
|
|
var rect = new Rect
|
|
|
|
{
|
|
|
|
x = EditorGUIUtility.currentViewWidth - 24,
|
|
|
|
y = 5,
|
|
|
|
width = 24,
|
|
|
|
height = 24
|
|
|
|
};
|
|
|
|
var content = EditorGUIUtility.IconContent("Settings");
|
|
|
|
content.tooltip = "点击打开HybridCLR Settings";
|
|
|
|
if (GUI.Button(rect, content, GUI.skin.GetStyle("IconButton")))
|
|
|
|
{
|
|
|
|
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
|
|
|
|
}
|
2022-11-28 12:20:52 +08:00
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
GUILayout.Space(10f);
|
2022-11-09 11:28:09 +08:00
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
EditorGUILayout.BeginVertical("box");
|
2022-12-06 11:52:47 +08:00
|
|
|
bool hasInstall = _controller.HasInstalledHybridCLR();
|
2022-10-25 17:26:21 +08:00
|
|
|
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
2022-11-28 12:20:52 +08:00
|
|
|
|
2022-10-25 17:26:21 +08:00
|
|
|
if (hasInstall)
|
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
EditorGUILayout.LabelField($"HybridCLR 版本: {_controller.HybridclrLocalVersion}");
|
2022-11-09 11:28:09 +08:00
|
|
|
GUILayout.Space(5f);
|
2022-12-06 11:52:47 +08:00
|
|
|
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
2022-11-09 11:28:09 +08:00
|
|
|
GUILayout.Space(5f);
|
2022-11-28 12:20:52 +08:00
|
|
|
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
|
|
|
//GUILayout.Space(40f);
|
2022-10-25 17:26:21 +08:00
|
|
|
}
|
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
GUILayout.Space(10f);
|
2022-11-28 12:20:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
2022-11-29 09:23:24 +08:00
|
|
|
EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或branch或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
|
2022-11-28 12:20:52 +08:00
|
|
|
_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
2022-12-06 11:52:47 +08:00
|
|
|
EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或branch或tag)(默认取{_controller.MajorVersion}-main分支最新版本):", GUILayout.MaxWidth(400));
|
2022-11-28 12:20:52 +08:00
|
|
|
_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
|
|
|
|
|
|
|
2022-12-06 11:52:47 +08:00
|
|
|
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
2022-09-22 08:56:07 +08:00
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
}
|
|
|
|
|
2022-12-06 11:52:47 +08:00
|
|
|
private void GUIInstallButton(string content, string button)
|
2022-09-22 08:56:07 +08:00
|
|
|
{
|
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
EditorGUILayout.LabelField(content);
|
|
|
|
if (GUILayout.Button(button, GUILayout.Width(100)))
|
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
InstallLocalHybridCLR();
|
2022-09-22 08:56:07 +08:00
|
|
|
GUIUtility.ExitGUI();
|
|
|
|
}
|
|
|
|
EditorGUILayout.EndHorizontal();
|
2022-10-09 03:25:56 +08:00
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
}
|
|
|
|
|
2022-12-06 11:52:47 +08:00
|
|
|
private void InstallLocalHybridCLR()
|
2022-10-25 17:26:21 +08:00
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
if (!_controller.IsComaptibleVersion())
|
2022-10-25 17:26:21 +08:00
|
|
|
{
|
2022-12-06 11:52:47 +08:00
|
|
|
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
|
|
|
return;
|
2022-10-25 17:26:21 +08:00
|
|
|
}
|
2022-12-06 11:52:47 +08:00
|
|
|
_controller.InstallLocalHybridCLR(_hybridclrVersion, _il2cppPlusVersion);
|
2022-10-25 17:26:21 +08:00
|
|
|
}
|
2022-09-22 08:56:07 +08:00
|
|
|
}
|
|
|
|
}
|