【m】hybrid更新为8.11.0
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 3s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 5s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 8s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 34s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 2s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 17s
Plugin Library CI / publish (07.RKTools) (push) Successful in 4s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 17s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 4s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s

This commit is contained in:
2026-04-13 22:59:23 +08:00
parent a7902e8224
commit a441a06257
20 changed files with 335 additions and 121 deletions

View File

@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybridCLR.Editor.ABI
{
public static class ABIUtil
{
public static string GetHybridCLRPlatformMacro(PlatformABI abi)
{
switch(abi)
{
case PlatformABI.Arm64: return "HYBRIDCLR_ABI_ARM_64";
case PlatformABI.Universal64: return "HYBRIDCLR_ABI_UNIVERSAL_64";
case PlatformABI.Universal32: return "HYBRIDCLR_ABI_UNIVERSAL_32";
case PlatformABI.WebGL32: return "HYBRIDCLR_ABI_WEBGL32";
default: throw new NotSupportedException();
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: edeb86f4b5b13ca4cb0fe9d87ce509bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -46,12 +46,21 @@ namespace HybridCLR.Editor.BuildProcessors
return;
}
BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
#if UNITY_6000_0_OR_NEWER
NamedBuildTarget namedBuildTarget = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup);
ScriptingImplementation curScriptingImplementation = PlayerSettings.GetScriptingBackend(namedBuildTarget);
#else
ScriptingImplementation curScriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup);
#endif
ScriptingImplementation targetScriptingImplementation = ScriptingImplementation.IL2CPP;
if (curScriptingImplementation != targetScriptingImplementation)
{
Debug.LogError($"[CheckSettings] current ScriptingBackend:{curScriptingImplementation}have been switched to:{targetScriptingImplementation} automatically");
#if UNITY_6000_0_OR_NEWER
PlayerSettings.SetScriptingBackend(namedBuildTarget, targetScriptingImplementation);
#else
PlayerSettings.SetScriptingBackend(buildTargetGroup, targetScriptingImplementation);
#endif
}
var installer = new Installer.InstallerController();

View File

@@ -64,6 +64,9 @@ namespace HybridCLR.Editor.BuildProcessors
return $"{projectDir}/Library/Bee/artifacts/PS4PlayerBuildProgram/ManagedStripped";
case BuildTarget.PS5:
return $"{projectDir}/Library/Bee/artifacts/PS5PlayerBuildProgram/ManagedStripped";
case BuildTarget.GameCoreXboxOne:
case BuildTarget.GameCoreXboxSeries:
return $"{projectDir}/Library/Bee/artifacts/GameCorePlayerBuildProgram/ManagedStripped";
#if UNITY_WEIXINMINIGAME
case BuildTarget.WeixinMiniGame:
return $"{projectDir}/Library/Bee/artifacts/WeixinMiniGame/ManagedStripped";

View File

@@ -9,7 +9,6 @@ using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
using static UnityEngine.Networking.UnityWebRequest;
namespace HybridCLR.Editor.Commands
{
@@ -136,8 +135,8 @@ namespace HybridCLR.Editor.Commands
options = buildOptions,
target = target,
targetGroup = BuildPipeline.GetBuildTargetGroup(target),
#if UNITY_2021_1_OR_NEWER
subtarget = (int)EditorUserBuildSettings.standaloneBuildSubtarget,
#if UNITY_SERVER
subtarget = (int)StandaloneBuildSubtarget.Server,
#endif
};

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9343e3f36d5deca4880d49f48b3fa2b1
guid: 2373f786d14518f44b0f475db77ba4de
AssemblyDefinitionImporter:
externalObjects: {}
userData:

View File

@@ -102,42 +102,23 @@ namespace HybridCLR.Editor.Installer
}
Directory.CreateDirectory(dir);
}
private static void CopyWithCheckLongFile(string srcFile, string dstFile)
{
var maxPathLength = 255;
#if UNITY_EDITOR_OSX
maxPathLength = 1024;
#endif
if (srcFile.Length > maxPathLength)
{
UnityEngine.Debug.LogError($"srcFile:{srcFile} path is too long. skip copy!");
return;
}
if (dstFile.Length > maxPathLength)
{
UnityEngine.Debug.LogError($"dstFile:{dstFile} path is too long. skip copy!");
return;
}
File.Copy(srcFile, dstFile);
}
public static void CopyDir(string src, string dst, bool log = false)
{
if (log)
{
UnityEngine.Debug.Log($"[BashUtil] CopyDir {src} => {dst}");
}
RemoveDir(dst);
Directory.CreateDirectory(dst);
foreach(var file in Directory.GetFiles(src))
if (Directory.Exists(dst))
{
CopyWithCheckLongFile(file, $"{dst}/{Path.GetFileName(file)}");
RemoveDir(dst);
}
foreach(var subDir in Directory.GetDirectories(src))
else
{
CopyDir(subDir, $"{dst}/{Path.GetFileName(subDir)}");
string parentDir = Path.GetDirectoryName(Path.GetFullPath(dst));
Directory.CreateDirectory(parentDir);
}
UnityEditor.FileUtil.CopyFileOrDirectory(src, dst);
}
}
}

View File

@@ -1,3 +1,6 @@
#if UNITY_6000_3_OR_NEWER && UNITY_EDITOR_OSX
#define NEW_IL2CPP_PATH
#endif
using System;
using System.Collections.Generic;
using System.IO;
@@ -8,6 +11,7 @@ using Debug = UnityEngine.Debug;
using System.Text.RegularExpressions;
using System.Linq;
using HybridCLR.Editor.Settings;
using System.Runtime.InteropServices;
namespace HybridCLR.Editor.Installer
{
@@ -33,7 +37,15 @@ namespace HybridCLR.Editor.Installer
{
_curVersion = ParseUnityVersion(Application.unityVersion);
_versionManifest = GetHybridCLRVersionManifest();
_curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => _curVersion.isTuanjieEngine ? v.unity_version == $"{_curVersion.major}-tuanjie" : v.unity_version == _curVersion.major.ToString());
_curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => {
return _curVersion.isTuanjieEngine? v.unity_version == $"{_curVersion.major}-tuanjie"
#if UNITY_6000_3_OR_NEWER
: v.unity_version == "6000.3.x"
#else
: v.unity_version == _curVersion.major.ToString()
#endif
;
});
PackageVersion = LoadPackageInfo().version;
InstalledLibil2cppVersion = ReadLocalVersion();
}
@@ -127,7 +139,11 @@ namespace HybridCLR.Editor.Installer
case 2021: return "2021.3.0";
case 2022: return "2022.3.0";
case 2023: return "2023.2.0";
#if UNITY_6000_3_OR_NEWER
case 6000: return "6000.3.0";
#else
case 6000: return "6000.0.0";
#endif
default: return $"2020.3.0";
}
}
@@ -158,14 +174,28 @@ namespace HybridCLR.Editor.Installer
public string Il2cppPlusLocalVersion => _curDefaultVersion?.il2cpp_plus?.branch;
private string GetIl2CppPathByContentPath(string contentPath)
public string ApplicationIl2cppPath
{
return $"{contentPath}/il2cpp";
get
{
Debug.Log($"application path:{EditorApplication.applicationPath} {EditorApplication.applicationContentsPath}");
#if NEW_IL2CPP_PATH
#if UNITY_IOS
string platformDirName = "iOSSupport";
#elif UNITY_TVOS
string platformDirName = "AppleTVSupport";
#elif UNITY_VISIONOS
string platformDirName = "VisionOSPlayer";
#else
string platformDirName = "iOSSupport";
#endif
return $"{EditorApplication.applicationContentsPath}/../../PlaybackEngines/{platformDirName}/il2cpp";
#else
return $"{EditorApplication.applicationContentsPath}/il2cpp";
#endif
}
}
public string ApplicationIl2cppPath => GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath);
public string LocalVersionFile => $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/libil2cpp-version.txt";
private string ReadLocalVersion()
@@ -266,12 +296,23 @@ namespace HybridCLR.Editor.Installer
// create LocalIl2Cpp
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
BashUtil.RecreateDir(localUnityDataDir);
#if !NEW_IL2CPP_PATH
// copy MonoBleedingEdge
BashUtil.CopyDir($"{Directory.GetParent(editorIl2cppPath)}/MonoBleedingEdge", $"{localUnityDataDir}/MonoBleedingEdge", true);
#endif
// copy il2cpp
BashUtil.CopyDir(editorIl2cppPath, SettingsUtil.LocalIl2CppDir, true);
#if NEW_IL2CPP_PATH
string buildDir = $"{SettingsUtil.LocalIl2CppDir}/build";
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm || RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
BashUtil.CopyDir($"{buildDir}/deploy_arm64", $"{buildDir}/deploy", false);
}
else
{
BashUtil.CopyDir($"{buildDir}/deploy_x86_64", $"{buildDir}/deploy", false);
}
#endif
// replace libil2cpp
string dstLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";

View File

@@ -5,5 +5,7 @@ namespace HybridCLR.Editor.MethodBridge
public class CallNativeMethodSignatureInfo
{
public MethodSig MethodSig { get; set; }
public CallingConvention? Callvention { get; set; }
}
}

View File

@@ -287,6 +287,7 @@ namespace HybridCLR.Editor.MethodBridge
CollectStructDefs(_managed2NativeMethodList0, structTypeSet);
CollectStructDefs(_native2ManagedMethodList0, structTypeSet);
CollectStructDefs(_adjustThunkMethodList0, structTypeSet);
CollectStructDefs(_originalCalliMethodSignatures.Select(m => m.MethodSig).ToList(), structTypeSet);
_structTypes0 = structTypeSet.ToList();
_structTypes0.Sort((a, b) => a.TypeId - b.TypeId);
@@ -558,6 +559,11 @@ namespace HybridCLR.Editor.MethodBridge
{
return CallingConvention.Winapi;
}
if (monoPInvokeCallbackAttr.ConstructorArguments.Count == 0)
{
Debug.LogError($"MonoPInvokeCallbackAttribute on method {method.FullName} has no constructor arguments. Using CallingConvention.Winapi as default.");
return CallingConvention.Winapi;
}
object delegateTypeSig = monoPInvokeCallbackAttr.ConstructorArguments[0].Value;
TypeDef delegateTypeDef;
@@ -579,7 +585,7 @@ namespace HybridCLR.Editor.MethodBridge
throw new NotSupportedException($"Unsupported delegate type: {delegateTypeSig}");
}
var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute");
if (attr == null)
if (attr == null || attr.ConstructorArguments.Count == 0)
{
return CallingConvention.Winapi;
}
@@ -637,7 +643,7 @@ namespace HybridCLR.Editor.MethodBridge
sharedMethod.Init();
sharedMethod = ToIsomorphicMethod(sharedMethod);
CallingConvention callingConv = (CallingConvention)((int)(method.MethodSig.CallingConvention & dnlib.DotNet.CallingConvention.Mask) + 1);
CallingConvention callingConv = (CallingConvention)((int)((method.Callvention ?? method.MethodSig.CallingConvention) & dnlib.DotNet.CallingConvention.Mask) + 1);
string signature = MakeCalliSignature(sharedMethod, callingConv);
if (!methodsBySig.TryGetValue(signature, out var arm))
@@ -829,6 +835,38 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
}
private void CollectStructDefs(List<MethodSig> methods, HashSet<TypeInfo> structTypes)
{
ICorLibTypes corLibTypes = _genericMethods[0].Method.Module.CorLibTypes;
foreach (var method in methods)
{
foreach (var paramInfo in method.Params)
{
var paramType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, paramInfo));
if (paramType.IsStruct)
{
structTypes.Add(paramType);
if (paramType.Klass.ContainsGenericParameter)
{
throw new Exception($"[CollectStructDefs] method:{method} type:{paramType.Klass} contains generic parameter");
}
}
}
var returnType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, method.RetType));
if (returnType.IsStruct)
{
structTypes.Add(returnType);
if (returnType.Klass.ContainsGenericParameter)
{
throw new Exception($"[CollectStructDefs] method:{method} type:{returnType.Klass} contains generic parameter");
}
}
}
}
class FieldInfo
{
public FieldDef field;

View File

@@ -3,6 +3,7 @@ using HybridCLR.Editor.Meta;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
@@ -26,6 +27,19 @@ namespace HybridCLR.Editor.MethodBridge
}
}
private CallingConvention GetCallingConvention(MethodDef method)
{
switch (method.ImplMap.CallConv)
{
case PInvokeAttributes.CallConvWinapi: return CallingConvention.Default;
case PInvokeAttributes.CallConvCdecl: return CallingConvention.C;
case PInvokeAttributes.CallConvStdCall: return CallingConvention.StdCall;
case PInvokeAttributes.CallConvThiscall: return CallingConvention.ThisCall;
case PInvokeAttributes.CallConvFastcall: return CallingConvention.FastCall;
default: return CallingConvention.Default;
}
}
public void Run()
{
foreach (var mod in _rootModules)
@@ -40,7 +54,11 @@ namespace HybridCLR.Editor.MethodBridge
{
Debug.LogError($"PInvoke method {method.FullName} has unsupported parameter or return type. Please check the method signature.");
}
_pinvokeMethodSignatures.Add(new CallNativeMethodSignatureInfo { MethodSig = method.MethodSig });
_pinvokeMethodSignatures.Add(new CallNativeMethodSignatureInfo
{
MethodSig = method.MethodSig,
Callvention = method.HasImplMap? GetCallingConvention(method) : (CallingConvention?)null,
});
}
}
}

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 259c1cb7fe681f74eb435ab8f268890d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,7 +8,7 @@ namespace HybridCLR.Editor.Settings
{
[MenuItem("HybridCLR/About", priority = 0)]
public static void OpenAbout() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/intro");
public static void OpenAbout() => Application.OpenURL("https://www.hybridclr.cn/docs/intro");
[MenuItem("HybridCLR/Installer...", priority = 60)]
private static void Open()
@@ -21,19 +21,19 @@ namespace HybridCLR.Editor.Settings
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
[MenuItem("HybridCLR/Documents/Quick Start")]
public static void OpenQuickStart() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart");
public static void OpenQuickStart() => Application.OpenURL("https://www.hybridclr.cn/docs/beginner/quickstart");
[MenuItem("HybridCLR/Documents/Performance")]
public static void OpenPerformance() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/basic/performance");
public static void OpenPerformance() => Application.OpenURL("https://www.hybridclr.cn/docs/basic/performance");
[MenuItem("HybridCLR/Documents/FAQ")]
public static void OpenFAQ() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/faq");
public static void OpenFAQ() => Application.OpenURL("https://www.hybridclr.cn/docs/help/faq");
[MenuItem("HybridCLR/Documents/Common Errors")]
public static void OpenCommonErrors() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/commonerrors");
public static void OpenCommonErrors() => Application.OpenURL("https://www.hybridclr.cn/docs/help/commonerrors");
[MenuItem("HybridCLR/Documents/Bug Report")]
public static void OpenBugReport() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/issue");
public static void OpenBugReport() => Application.OpenURL("https://www.hybridclr.cn/docs/help/issue");
}
}