2022-09-22 08:56:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEditor.Build;
|
|
|
|
|
using UnityEditor.Build.Reporting;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace HybridCLR.Editor.BuildProcessors
|
|
|
|
|
{
|
|
|
|
|
internal class CheckSettings : IPreprocessBuildWithReport
|
|
|
|
|
{
|
|
|
|
|
public int callbackOrder => 0;
|
|
|
|
|
|
|
|
|
|
public void OnPreprocessBuild(BuildReport report)
|
|
|
|
|
{
|
2022-10-09 16:13:23 +08:00
|
|
|
|
HybridCLRGlobalSettings globalSettings = SettingsUtil.GlobalSettings;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
#if !UNITY_2020_1_OR_NEWER || !UNITY_IOS
|
2022-10-09 16:13:23 +08:00
|
|
|
|
if (!globalSettings.enable || globalSettings.useGlobalIl2Cpp)
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
string oldIl2cppPath = Environment.GetEnvironmentVariable("UNITY_IL2CPP_PATH");
|
|
|
|
|
if (!string.IsNullOrEmpty(oldIl2cppPath))
|
|
|
|
|
{
|
|
|
|
|
Environment.SetEnvironmentVariable("UNITY_IL2CPP_PATH", "");
|
|
|
|
|
Debug.Log($"[CheckSettings] 清除 UNITY_IL2CPP_PATH, 旧值为:'{oldIl2cppPath}'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string curIl2cppPath = Environment.GetEnvironmentVariable("UNITY_IL2CPP_PATH");
|
|
|
|
|
if (curIl2cppPath != SettingsUtil.LocalIl2CppDir)
|
|
|
|
|
{
|
|
|
|
|
Environment.SetEnvironmentVariable("UNITY_IL2CPP_PATH", SettingsUtil.LocalIl2CppDir);
|
|
|
|
|
Debug.Log($"[CheckSettings] UNITY_IL2CPP_PATH 当前值为:'{curIl2cppPath}',更新为:'{SettingsUtil.LocalIl2CppDir}'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2022-10-09 16:13:23 +08:00
|
|
|
|
if (!globalSettings.enable)
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (UnityEditor.PlayerSettings.gcIncremental)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError($"[CheckSettings] HybridCLR不支持增量式GC,已经自动将该选项关闭");
|
|
|
|
|
UnityEditor.PlayerSettings.gcIncremental = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var installer = new Installer.InstallerController();
|
|
|
|
|
if (!installer.HasInstalledHybridCLR())
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"你没有初始化HybridCLR,请通过菜单'HybridCLR/Installer'安装");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HybridCLRGlobalSettings gs = SettingsUtil.GlobalSettings;
|
|
|
|
|
if (((gs.hotUpdateAssemblies?.Length + gs.hotUpdateAssemblyDefinitions?.Length) ?? 0) == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"GlobalSettings中未配置热更新dll");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|