mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07b52bed05 | |||
| 3139fbefa6 | |||
| fbeeb3d959 | |||
| 1f4e754adb | |||
| f63bbc8a52 | |||
| b17751b8a8 | |||
| 05e721cf02 | |||
| 29646f1294 | |||
| 3702411ac8 | |||
| d205f00a1b | |||
| 2894701063 | |||
| 1045538b40 | |||
| 8fd9b2ec82 | |||
| 0ccdd424ab | |||
| c083e4ada4 | |||
| 4c6dd1249a | |||
| b8b990bfc1 | |||
| 252e6add67 | |||
| 6e76b96f97 | |||
| dd18ecdba5 | |||
| 2ff3e276d2 | |||
| 1d5f2a953c | |||
| 75cb53cb19 | |||
| c84f575a2e | |||
| 3beb788baa | |||
| 6909c32a0c |
@@ -1,5 +0,0 @@
|
||||
# change logs
|
||||
|
||||
- 2022.8.30 创建
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f2a6638b09b52f4c9dc8906d090b710
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d104ab5da8136154899a40116dc88731
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,18 +2,18 @@
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2019",
|
||||
"hybridclr" : { "branch":"v2.0.3"},
|
||||
"il2cpp_plus": { "branch":"v2019-2.0.1"}
|
||||
"hybridclr" : { "branch":"v2.3.0"},
|
||||
"il2cpp_plus": { "branch":"v2019-2.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2020",
|
||||
"hybridclr" : { "branch":"v2.0.3"},
|
||||
"il2cpp_plus": { "branch":"v2020-2.0.2"}
|
||||
"hybridclr" : { "branch":"v2.3.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-2.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v2.0.3"},
|
||||
"il2cpp_plus": { "branch":"v2021-2.0.2"}
|
||||
"hybridclr" : { "branch":"v2.3.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-2.2.0"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -42,11 +42,11 @@ namespace HybridCLR.Editor.UnityBinFileReader
|
||||
writer.Write(new EndianBinaryWriter(output));
|
||||
Debug.Log($"patch file:{dataunity3dFile} size:{output.Length}");
|
||||
|
||||
string bakFile = dataunity3dFile + ".bak";
|
||||
if (!File.Exists(bakFile))
|
||||
{
|
||||
File.Copy(dataunity3dFile, bakFile);
|
||||
}
|
||||
//string bakFile = dataunity3dFile + ".bak";
|
||||
//if (!File.Exists(bakFile))
|
||||
//{
|
||||
// File.Copy(dataunity3dFile, bakFile);
|
||||
//}
|
||||
File.WriteAllBytes(dataunity3dFile, output.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Runtime.CompilerServices;
|
||||
using MonoHook;
|
||||
using HybridCLR.Editor.BuildProcessors;
|
||||
using System.IO;
|
||||
|
||||
namespace HybridCLR.MonoHook
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER && UNITY_WEBGL
|
||||
[InitializeOnLoad]
|
||||
public class PatchScriptingAssembliesJsonHook
|
||||
{
|
||||
private static MethodHook _hook;
|
||||
|
||||
static PatchScriptingAssembliesJsonHook()
|
||||
{
|
||||
if (_hook == null)
|
||||
{
|
||||
Type type = typeof(UnityEditor.EditorApplication);
|
||||
MethodInfo miTarget = type.GetMethod("BuildMainWindowTitle", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
|
||||
MethodInfo miReplacement = new Func<string>(BuildMainWindowTitle).Method;
|
||||
MethodInfo miProxy = new Func<string>(BuildMainWindowTitleProxy).Method;
|
||||
|
||||
_hook = new MethodHook(miTarget, miReplacement, miProxy);
|
||||
_hook.Install();
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildMainWindowTitle()
|
||||
{
|
||||
string tempJsonPath = $"{Application.dataPath}/../Library/PlayerDataCache/WebGL/Data/ScriptingAssemblies.json";
|
||||
if (File.Exists(tempJsonPath))
|
||||
{
|
||||
var patcher = new PatchScriptingAssemblyList();
|
||||
patcher.PathScriptingAssembilesFile(Path.GetDirectoryName(tempJsonPath));
|
||||
}
|
||||
string newTitle = BuildMainWindowTitleProxy();
|
||||
return newTitle;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoOptimization)]
|
||||
private static string BuildMainWindowTitleProxy()
|
||||
{
|
||||
// 为满足MonoHook要求的最小代码长度而特地加入的无用填充代码,
|
||||
UnityEngine.Debug.Log(12345.ToString());
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc89a9041ab48ac41975fbd1e00b9b98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Desc: 一个可以运行时 Hook Mono 方法的工具,让你可以无需修改 UnityEditor.dll 等文件就可以重写其函数功能
|
||||
Author: Misaka Mikoto
|
||||
Github: https://github.com/Misaka-Mikoto-Tech/MonoHook
|
||||
@@ -85,7 +85,7 @@ namespace MonoHook
|
||||
|
||||
private CodePatcher _codePatcher;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||
/// <summary>
|
||||
/// call `MethodInfo.MethodHandle.GetFunctionPointer()`
|
||||
/// will visit static class `UnityEditor.IMGUI.Controls.TreeViewGUI.Styles` and invoke its static constructor,
|
||||
@@ -97,7 +97,7 @@ namespace MonoHook
|
||||
|
||||
static MethodHook()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||
s_fi_GUISkin_current = typeof(GUISkin).GetField("current", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
#endif
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace MonoHook
|
||||
if (isHooked)
|
||||
return;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||
if (s_fi_GUISkin_current.GetValue(null) != null)
|
||||
DoInstall();
|
||||
else
|
||||
@@ -191,7 +191,7 @@ namespace MonoHook
|
||||
if (targetMethod.IsAbstract)
|
||||
throw new Exception($"WRANING: you can not hook abstract method [{methodName}]");
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||
int minMethodBodySize = 10;
|
||||
|
||||
{
|
||||
@@ -358,7 +358,7 @@ namespace MonoHook
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||
private void OnEditorUpdate()
|
||||
{
|
||||
if (s_fi_GUISkin_current.GetValue(null) != null)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82346623158bae349a8347ae74662b12
|
||||
guid: 16b9dc031f67b4fe5ad79c230f75768c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace HybridCLR.Editor.ABI
|
||||
case ElementType.Module:
|
||||
case ElementType.Var:
|
||||
case ElementType.MVar:
|
||||
return GetNativeIntTypeInfo();
|
||||
return GetNativeIntTypeInfo();
|
||||
case ElementType.TypedByRef: return CreateValueType(type);
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
@@ -105,7 +105,7 @@ namespace HybridCLR.Editor.ABI
|
||||
|
||||
private static bool IsNotHFAFastCheck(int typeSize)
|
||||
{
|
||||
return typeSize != 8 && typeSize != 12 && typeSize != 16 && typeSize != 24 && typeSize != 32;
|
||||
return typeSize % 4 != 0 || typeSize > 32;
|
||||
}
|
||||
|
||||
private static bool ComputHFATypeInfo0(TypeSig type, HFATypeInfo typeInfo)
|
||||
@@ -169,7 +169,7 @@ namespace HybridCLR.Editor.ABI
|
||||
return false;
|
||||
}
|
||||
bool ok = ComputHFATypeInfo0(type, typeInfo);
|
||||
if (ok && typeInfo.Count >= 2 && typeInfo.Count <= 4)
|
||||
if (ok && typeInfo.Count >= 1 && typeInfo.Count <= 4)
|
||||
{
|
||||
int fieldSize = typeInfo.Type.ElementType == ElementType.R4 ? 4 : 8;
|
||||
return typeSize == fieldSize * typeInfo.Count;
|
||||
@@ -261,7 +261,15 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return fields.All(f => f.IsStatic);
|
||||
if (fields.All(f => f.IsStatic))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (typeDef.IsExplicitLayout && fields.Count(f => !f.IsStatic) > 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static TypeInfo CreateGeneralValueType(TypeSig type, int size, int aligment)
|
||||
@@ -285,6 +293,7 @@ namespace HybridCLR.Editor.ABI
|
||||
bool isFloat = hfaTypeInfo.Type.ElementType == ElementType.R4;
|
||||
switch (hfaTypeInfo.Count)
|
||||
{
|
||||
case 1: return isFloat ? TypeInfo.s_r4 : TypeInfo.s_r8;
|
||||
case 2: return isFloat ? TypeInfo.s_vf2 : TypeInfo.s_vd2;
|
||||
case 3: return isFloat ? TypeInfo.s_vf3 : TypeInfo.s_vd3;
|
||||
case 4: return isFloat ? TypeInfo.s_vf4 : TypeInfo.s_vd4;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
public override bool IsArch32 => false;
|
||||
|
||||
public override bool IsSupportHFA => true;
|
||||
public override bool IsSupportHFA => false;
|
||||
|
||||
protected override TypeInfo OptimizeSigType(TypeInfo type, bool returnType)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,6 +12,52 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
public class GenericReferenceWriter
|
||||
{
|
||||
private static readonly Dictionary<Type, string> _typeNameMapping = new Dictionary<Type, string>
|
||||
{
|
||||
{typeof(bool), "bool" },
|
||||
{typeof(byte), "byte" },
|
||||
{typeof(sbyte), "sbyte" },
|
||||
{typeof(short), "short" },
|
||||
{typeof(ushort), "ushort" },
|
||||
{typeof(int), "int" },
|
||||
{typeof(uint), "uint" },
|
||||
{typeof(long), "long" },
|
||||
{typeof(ulong), "ulong" },
|
||||
{typeof(float), "float" },
|
||||
{typeof(double), "double" },
|
||||
{typeof(object), "object" },
|
||||
{typeof(string), "string" },
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, string> _typeSimpleNameMapping = new Dictionary<string, string>();
|
||||
private readonly Regex _systemTypePattern;
|
||||
private readonly Regex _genericPattern = new Regex(@"`\d+");
|
||||
|
||||
public GenericReferenceWriter()
|
||||
{
|
||||
foreach (var e in _typeNameMapping)
|
||||
{
|
||||
_typeSimpleNameMapping.Add(e.Key.FullName, e.Value);
|
||||
}
|
||||
_systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{k}\b")));
|
||||
}
|
||||
|
||||
public string PrettifyTypeSig(string typeSig)
|
||||
{
|
||||
string s = _genericPattern.Replace(typeSig, "").Replace('/', '.');
|
||||
return _systemTypePattern.Replace(s, m => _typeSimpleNameMapping[m.Groups[0].Value]);
|
||||
}
|
||||
|
||||
public string PrettifyMethodSig(string methodSig)
|
||||
{
|
||||
string s = PrettifyTypeSig(methodSig).Replace("::", ".");
|
||||
if (s.Contains(".ctor("))
|
||||
{
|
||||
s = "new " + s.Replace(".ctor(", "(");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void Write(List<GenericClass> types, List<GenericMethod> methods, string outputFile)
|
||||
{
|
||||
string parentDir = Directory.GetParent(outputFile).FullName;
|
||||
@@ -20,18 +67,30 @@ namespace HybridCLR.Editor.AOT
|
||||
codes.Add("public class AOTGenericReferences : UnityEngine.MonoBehaviour");
|
||||
codes.Add("{");
|
||||
|
||||
codes.Add("");
|
||||
codes.Add("\t// {{ AOT assemblies");
|
||||
List<dnlib.DotNet.ModuleDef> modules = new HashSet<dnlib.DotNet.ModuleDef>(
|
||||
types.Select(t => t.Type.Module).Concat(methods.Select(m => m.Method.Module))).ToList();
|
||||
modules.Sort((a, b) => a.Name.CompareTo(b.Name));
|
||||
foreach (dnlib.DotNet.ModuleDef module in modules)
|
||||
{
|
||||
codes.Add($"\t// {module.Name}");
|
||||
}
|
||||
codes.Add("\t// }}");
|
||||
|
||||
|
||||
codes.Add("");
|
||||
codes.Add("\t// {{ constraint implement type");
|
||||
|
||||
codes.Add("\t// }} ");
|
||||
|
||||
codes.Add("");
|
||||
codes.Add("\t// {{ AOT generic type");
|
||||
codes.Add("\t// {{ AOT generic types");
|
||||
|
||||
types.Sort((a, b) => a.Type.FullName.CompareTo(b.Type.FullName));
|
||||
foreach(var type in types)
|
||||
{
|
||||
codes.Add($"\t//{type.ToTypeSig()}");
|
||||
codes.Add($"\t// {PrettifyTypeSig(type.ToTypeSig().ToString())}");
|
||||
}
|
||||
|
||||
codes.Add("\t// }}");
|
||||
@@ -51,7 +110,7 @@ namespace HybridCLR.Editor.AOT
|
||||
});
|
||||
foreach(var method in methods)
|
||||
{
|
||||
codes.Add($"\t\t// {method.ToMethodSpec()}");
|
||||
codes.Add($"\t\t// {PrettifyMethodSig(method.ToMethodSpec().ToString())}");
|
||||
}
|
||||
codes.Add("\t}");
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
@@ -40,10 +41,32 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (UnityEditor.PlayerSettings.gcIncremental)
|
||||
if (PlayerSettings.gcIncremental)
|
||||
{
|
||||
Debug.LogError($"[CheckSettings] HybridCLR不支持增量式GC,已经自动将该选项关闭");
|
||||
UnityEditor.PlayerSettings.gcIncremental = false;
|
||||
PlayerSettings.gcIncremental = false;
|
||||
}
|
||||
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
ScriptingImplementation curScriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup);
|
||||
ScriptingImplementation targetScriptingImplementation = ScriptingImplementation.IL2CPP;
|
||||
if (curScriptingImplementation != targetScriptingImplementation)
|
||||
{
|
||||
Debug.LogError($"[CheckSettings] 当前ScriptingBackend是:{curScriptingImplementation},已经自动切换为:{targetScriptingImplementation}");
|
||||
PlayerSettings.SetScriptingBackend(buildTargetGroup, targetScriptingImplementation);
|
||||
}
|
||||
ApiCompatibilityLevel curApiCompatibilityLevel = PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup);
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
ApiCompatibilityLevel targetApiCompatibilityLevel = ApiCompatibilityLevel.NET_Unity_4_8;
|
||||
#else
|
||||
ApiCompatibilityLevel targetApiCompatibilityLevel = ApiCompatibilityLevel.NET_4_6;
|
||||
#endif
|
||||
|
||||
|
||||
if (curApiCompatibilityLevel != targetApiCompatibilityLevel)
|
||||
{
|
||||
Debug.LogError($"[CheckSettings] 当前ApiCompatibilityLevel是:{curApiCompatibilityLevel},已经自动切换为 {targetApiCompatibilityLevel}。由于下一次打包才生效,主动打断本次打包。");
|
||||
PlayerSettings.SetApiCompatibilityLevel(buildTargetGroup, ApiCompatibilityLevel.NET_4_6);
|
||||
throw new BuildFailedException("ApiCompatibilityLevel error");
|
||||
}
|
||||
|
||||
var installer = new Installer.InstallerController();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
public class MsvcStdextWorkaround : IPreprocessBuildWithReport
|
||||
{
|
||||
const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
|
||||
|
||||
public int callbackOrder => 0;
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
var clEnv = Environment.GetEnvironmentVariable("_CL_");
|
||||
|
||||
if (string.IsNullOrEmpty(clEnv))
|
||||
{
|
||||
Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
|
||||
}
|
||||
else if (!clEnv.Contains(kWorkaroundFlag))
|
||||
{
|
||||
clEnv += " " + kWorkaroundFlag;
|
||||
Environment.SetEnvironmentVariable("_CL_", clEnv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UNITY_EDITOR
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bff6cadf0b8db54b87ba51b24d080f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -52,7 +52,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
#endif
|
||||
}
|
||||
|
||||
private void PathScriptingAssembilesFile(string path)
|
||||
public void PathScriptingAssembilesFile(string path)
|
||||
{
|
||||
if (!SettingsUtil.Enable)
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
UnityVersion = Application.unityVersion,
|
||||
HotUpdateAssemblies = SettingsUtil.HotUpdateAssemblyNamesIncludePreserved,
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/il2cpp-config.h",
|
||||
OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.cpp",
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/UnityVersion.h",
|
||||
OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/AssemblyManifest.cpp",
|
||||
};
|
||||
|
||||
var g = new Il2CppDef.Il2CppDefGenerator(options);
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace HybridCLR.Editor.Commands
|
||||
BashUtil.RemoveDir(outputPath);
|
||||
|
||||
var buildOptions = BuildOptions.BuildScriptsOnly;
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
buildOptions |= BuildOptions.CleanBuildCache;
|
||||
#endif
|
||||
|
||||
bool oldExportAndroidProj = EditorUserBuildSettings.exportAsGoogleAndroidProject;
|
||||
#if UNITY_EDITOR_OSX
|
||||
@@ -110,8 +113,7 @@ namespace HybridCLR.Editor.Commands
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
Debug.LogError("GenerateStripedAOTDlls 失败");
|
||||
return;
|
||||
throw new Exception("GenerateStripedAOTDlls 失败");
|
||||
}
|
||||
Debug.Log($"GenerateStripedAOTDlls target:{target} group:{group} path:{outputPath}");
|
||||
}
|
||||
|
||||
@@ -88,6 +88,21 @@ namespace HybridCLR.Editor.Installer
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
private static void CopyWithCheckLongFile(string srcFile, string dstFile)
|
||||
{
|
||||
if (srcFile.Length > 255)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"srcFile:{srcFile} path is too long. copy ignore!");
|
||||
return;
|
||||
}
|
||||
if (dstFile.Length > 255)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"dstFile:{dstFile} path is too long. copy ignore!");
|
||||
return;
|
||||
}
|
||||
File.Copy(srcFile, dstFile);
|
||||
}
|
||||
|
||||
public static void CopyDir(string src, string dst, bool log = false)
|
||||
{
|
||||
if (log)
|
||||
@@ -98,7 +113,7 @@ namespace HybridCLR.Editor.Installer
|
||||
Directory.CreateDirectory(dst);
|
||||
foreach(var file in Directory.GetFiles(src))
|
||||
{
|
||||
File.Copy(file, $"{dst}/{Path.GetFileName(file)}");
|
||||
CopyWithCheckLongFile(file, $"{dst}/{Path.GetFileName(file)}");
|
||||
}
|
||||
foreach(var subDir in Directory.GetDirectories(src))
|
||||
{
|
||||
|
||||
@@ -166,10 +166,11 @@ namespace HybridCLR.Editor.Installer
|
||||
return $"{contentPath}/il2cpp";
|
||||
}
|
||||
|
||||
public string ApplicationIl2cppPath => GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath);
|
||||
|
||||
public void InstallDefaultHybridCLR()
|
||||
{
|
||||
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), _curVersion);
|
||||
InstallFromLocal(PrepareLibil2cppWithHybridclrFromGitRepo());
|
||||
}
|
||||
|
||||
public bool HasInstalledHybridCLR()
|
||||
@@ -202,7 +203,42 @@ namespace HybridCLR.Editor.Installer
|
||||
BashUtil.RunCommand(workDir, "git", new string[] {"clone", "-b", branch, "--depth", "1", repoUrl, repoDir});
|
||||
}
|
||||
|
||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, UnityVersion version)
|
||||
private string PrepareLibil2cppWithHybridclrFromGitRepo()
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
Directory.CreateDirectory(workDir);
|
||||
//BashUtil.RecreateDir(workDir);
|
||||
|
||||
// clone hybridclr
|
||||
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
CloneBranch(workDir, hybridclrRepoURL, _curDefaultVersion.hybridclr.branch, hybridclrRepoDir);
|
||||
|
||||
if (!Directory.Exists(hybridclrRepoDir))
|
||||
{
|
||||
throw new Exception($"clone hybridclr fail. url: {hybridclrRepoURL}");
|
||||
}
|
||||
|
||||
// clone il2cpp_plus
|
||||
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
CloneBranch(workDir, il2cppPlusRepoURL, _curDefaultVersion.il2cpp_plus.branch, il2cppPlusRepoDir);
|
||||
|
||||
if (!Directory.Exists(il2cppPlusRepoDir))
|
||||
{
|
||||
throw new Exception($"clone il2cpp_plus fail. url: {il2cppPlusRepoDir}");
|
||||
}
|
||||
|
||||
Directory.Move($"{hybridclrRepoDir}/hybridclr", $"{il2cppPlusRepoDir}/libil2cpp/hybridclr");
|
||||
return $"{il2cppPlusRepoDir}/libil2cpp";
|
||||
}
|
||||
|
||||
public void InstallFromLocal(string libil2cppWithHybridclrSourceDir)
|
||||
{
|
||||
RunInitLocalIl2CppData(ApplicationIl2cppPath, libil2cppWithHybridclrSourceDir, _curVersion);
|
||||
}
|
||||
|
||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, string libil2cppWithHybridclrSourceDir, UnityVersion version)
|
||||
{
|
||||
if (!IsComaptibleVersion())
|
||||
{
|
||||
@@ -217,15 +253,6 @@ namespace HybridCLR.Editor.Installer
|
||||
BashUtil.RemoveDir(buildiOSDir);
|
||||
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
|
||||
|
||||
// clone hybridclr
|
||||
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
CloneBranch(workDir, hybridclrRepoURL, _curDefaultVersion.hybridclr.branch, hybridclrRepoDir);
|
||||
|
||||
// clone il2cpp_plus
|
||||
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
CloneBranch(workDir, il2cppPlusRepoURL, _curDefaultVersion.il2cpp_plus.branch, il2cppPlusRepoDir);
|
||||
|
||||
// create LocalIl2Cpp
|
||||
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
||||
@@ -239,8 +266,7 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
// replace libil2cpp
|
||||
string dstLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
BashUtil.CopyDir($"{il2cppPlusRepoDir}/libil2cpp", dstLibil2cppDir, true);
|
||||
BashUtil.CopyDir($"{hybridclrRepoDir}/hybridclr", $"{dstLibil2cppDir}/hybridclr", true);
|
||||
BashUtil.CopyDir($"{libil2cppWithHybridclrSourceDir}", dstLibil2cppDir, true);
|
||||
|
||||
// clean Il2cppBuildCache
|
||||
BashUtil.RemoveDir($"{SettingsUtil.ProjectDir}/Library/Il2cppBuildCache", true);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -10,6 +11,10 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
private InstallerController _controller;
|
||||
|
||||
private bool _installFromDir;
|
||||
|
||||
private string _installLibil2cppWithHybridclrSourceDir;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_controller = new InstallerController();
|
||||
@@ -66,6 +71,17 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private void GUIInstallButton(string content, string button)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
_installFromDir = EditorGUILayout.Toggle("从本地复制libil2cpp", _installFromDir);
|
||||
EditorGUI.BeginDisabledGroup(!_installFromDir);
|
||||
EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400));
|
||||
if (GUILayout.Button("选择目录", GUILayout.Width(100)))
|
||||
{
|
||||
_installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("选择libil2cpp目录", Application.dataPath, "libil2cpp");
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(content);
|
||||
if (GUILayout.Button(button, GUILayout.Width(100)))
|
||||
@@ -79,7 +95,24 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private void InstallLocalHybridCLR()
|
||||
{
|
||||
_controller.InstallDefaultHybridCLR();
|
||||
if (_installFromDir)
|
||||
{
|
||||
if (!Directory.Exists(_installLibil2cppWithHybridclrSourceDir))
|
||||
{
|
||||
Debug.LogError($"本地libil2cpp复制目录不存在. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||
return;
|
||||
}
|
||||
if (!File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/il2cpp-config.h") || !File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/hybridclr/RuntimeApi.cpp"))
|
||||
{
|
||||
Debug.LogError($"本地libil2cpp不是合法有效的源码目录. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||
return;
|
||||
}
|
||||
_controller.InstallFromLocal(_installLibil2cppWithHybridclrSourceDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
_controller.InstallDefaultHybridCLR();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@ namespace HybridCLR.Editor.Meta
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER && UNITY_IOS
|
||||
throw new Exception($"resolve assembly:{assemblyName} 失败! 请按照Install文档正确替换了UnityEditor.CoreModule.dll或者升级hybridclr_unity到2.0.1及更高版本");
|
||||
#else
|
||||
throw new Exception($"resolve assembly:{assemblyName} 失败! 请参阅常见错误文档");
|
||||
#endif
|
||||
if (SettingsUtil.HotUpdateAssemblyNamesIncludePreserved.Contains(assemblyName))
|
||||
{
|
||||
throw new Exception($"resolve 热更新 dll:{assemblyName} 失败!请确保已经编译了热更新dll或者外部热更新路径中配置了正确的值。更多请参阅常见错误文档");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"resolve AOT dll:{assemblyName} 失败! 请确保主工程已经引用了该dll并且正确生成了裁剪后的AOT dll。更多请参阅常见错误文档");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ Unity Package for HybridCLR
|
||||
|
||||
## 改动日志
|
||||
|
||||
- v2.3.0 支持从本地目录直接复制hybridclr源码。轻微修复2019版本某些情况下路径过长导致安装失败的问题。
|
||||
- v2.2.0 支持2020.3.47及2021.3.23
|
||||
- v2.0.5 Installer使用tag而不是commit id,安装时不必拉取整个branch,大幅缩短安装时间
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# 发布日志
|
||||
|
||||
## 2.4.1
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复遗漏 RELEASELOG.md.meta 文件的问题
|
||||
|
||||
## 2.4.0
|
||||
|
||||
### 改动
|
||||
|
||||
- CheckSettings中检查ScriptingBackend及ApiCompatibleLevel,切换为正确的值
|
||||
- hybridclr 升级到v2.3.0版本
|
||||
- il2cpp_plus 升级到v2019-2.2.0、v2020-2.2.0、v2021-2.2.0版本
|
||||
|
||||
### 修复
|
||||
|
||||
- 新增 MsvcStdextWorkaround.cs 解决2020 vs下stdext编译错误的问题
|
||||
- 修复当struct只包含一个float或double字段时,在arm64上计算桥接函数签名错误的bug
|
||||
|
||||
## 2.3.1
|
||||
|
||||
### 修复
|
||||
- 修复本地复制libil2cpp却仍然从仓库下载安装的bug
|
||||
|
||||
## 2.3.0
|
||||
|
||||
### 改动
|
||||
|
||||
- Installer支持从本地目录复制改造后的libil2cpp
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复2019版本MonoBleedingEdge的子目录中包含了过长路径的文件导致Installer复制文件出错的问题
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b2d5d0a85ef3bf44be6cbe94ed5ed2a
|
||||
guid: 8e53ce54bd8e88c4785c625555308dba
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "2.0.8",
|
||||
"version": "2.4.1",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
||||
Reference in New Issue
Block a user