focus-creative-games / hybridclr_unity Goto Github PK
View Code? Open in Web Editor NEWUnity package for HybridCLR
Home Page: https://code-philosophy.com/
License: MIT License
Unity package for HybridCLR
Home Page: https://code-philosophy.com/
License: MIT License
加载 A和B两个程序集,B里面对象继承A内的一个接口ISystem,在A里面利用反射创建这个对象时会导致强制类型转换失败
Type systemType; //这个类型是获取的继承ISystem的类 var constructorInfo = systemType.GetConstructor(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public, null, new Type[0], null); object obj=constructorInfo.Invoke(null); ISystem typeInstance = (ISystem)obj;
会抛出类型转换失败的异常
执行Generate -> MethodBridge
时,有概率出现下面的报错:
== output:E:\xxx\yyy\Client/HybridCLRData/LocalIl2CppData-WindowsEditor/il2cpp/libil2cpp/hybridclr/generated/MethodBridge_Arm64.cpp ==
== output:E:\xxx\yyy\Client/HybridCLRData/LocalIl2CppData-WindowsEditor/il2cpp/libil2cpp/hybridclr/generated/MethodBridge_Universal64.cpp ==
DirectoryNotFoundException: Could not find a part of the path 'E:\xxx\yyy\Client\Library\Il2cppBuildCache\Windows\x64\il2cppOutput\Data'.
System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].HandleError (System.Int32 hr, System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.FileSystemEnumerableIterator`1[TSource].CommonInit () (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.FileSystemEnumerableIterator`1[TSource]..ctor (System.String path, System.String originalUserPath, System.String searchPattern, System.IO.SearchOption searchOption, System.IO.SearchResultHandler`1[TSource] resultHandler, System.Boolean checkHost) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.FileSystemEnumerableFactory.CreateFileNameIterator (System.String path, System.String originalUserPath, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.InternalGetFileDirectoryNames (System.String path, System.String userPathOriginal, System.String searchPattern, System.Boolean includeFiles, System.Boolean includeDirs, System.IO.SearchOption searchOption, System.Boolean checkHost) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.InternalGetDirectories (System.String path, System.String searchPattern, System.IO.SearchOption searchOption) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.GetDirectories (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.RecursiveDelete (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.IO.Directory.Delete (System.String path, System.Boolean recursive) (at <695d1cc93cca45069c528c15c9fdd749>:0)
HybridCLR.Editor.Commands.MethodBridgeGeneratorCommand.CleanIl2CppBuildCache () (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@eee3dbaa69/Editor/Commands/MethodBridgeGeneratorCommand.cs:28)
HybridCLR.Editor.Commands.MethodBridgeGeneratorCommand.GenerateMethodBridgeCppFile (HybridCLR.Editor.MethodBridge.Analyzer analyzer, HybridCLR.Editor.ABI.PlatformABI platform, System.String templateCode, System.String outputFile) (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@eee3dbaa69/Editor/Commands/MethodBridgeGeneratorCommand.cs:45)
HybridCLR.Editor.Commands.MethodBridgeGeneratorCommand+<>c__DisplayClass3_2.<GenerateMethodBridge>b__0 () (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@eee3dbaa69/Editor/Commands/MethodBridgeGeneratorCommand.cs:80)
System.Threading.Tasks.Task.InnerInvoke () (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.Tasks.Task.Execute () (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as AggregateException: One or more errors occurred.
System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks, System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks, System.Int32 millisecondsTimeout) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks) (at <695d1cc93cca45069c528c15c9fdd749>:0)
HybridCLR.Editor.Commands.MethodBridgeGeneratorCommand.GenerateMethodBridge (System.Boolean compileDll) (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@eee3dbaa69/Editor/Commands/MethodBridgeGeneratorCommand.cs:83)
HybridCLR.Editor.Commands.MethodBridgeGeneratorCommand.GenerateMethodBridge () (at Library/PackageCache/com.focus-creative-games.hybridclr_unity@eee3dbaa69/Editor/Commands/MethodBridgeGeneratorCommand.cs:51)
项目里用到了7Zip,程序集命名的SevenZip,与Package中的SevenZip冲突,建议改名为SevenZip.Editor。
Unity Editor版本: 2021.3.1f1
操作系统: macOS Big Sur
出错的Build Target: WebGL
com.focus-creative-games.hybridclr_unity的版本号: 2.0.0
hybridclr仓库的版本号: main 531f98365eebce5d1390175be2b41c41e217d918
il2cpp_plus仓库的版本号: 2021-main 99cd1cbbfc1f637460379e81c9a7776cd3e662ad
截图及日志文件
复现条件 await UniTask报错,clone这个仓库https://gitee.com/poetao/hybridclr_test.git 直接打包webgl平台即可
出错的c#代码位置(如果能定位出的话)
Unity Editor版本: 2022.3.11f1, 2022.3.12f1
操作系统: Windows 11
出错的BuildTarget: Android
com.code-philosophy.hybridclr的版本号: 4.0.11, 4.0.12
复现条件:
1)把hybridclr_trial导入到2022.3.11f1,然后把hybridclr升级到4.0.12; 把编译选项切换到android平台
2)把ProjectSettings -> Editor的 -> Load texture data on demand选项 选上 后,运行GenerateAll步骤,unity会直接崩溃
如果这个选项没有选上,则正常
unity 2022.3.10lts 导出插件后崩溃。
大佬你好 我看文档说是
当 com.code-philosophy.hybridclr 版本 ≥ v3.2.0
不需要任何处理,直接导出xcode工程,再打包即可。由于在build完成后才将libil2cpp源码加入xcode工程,因此只能先导出xcode,再手动或者命令行编译,试图直接Build And Run会出错。
危险
由于xcode工程里写死了 libil2cpp相关代码的路径,如果你导出xcode工程,推送到其他电脑上打包,会出现代码文件找不到的错误!
那么就意味着如果我要出xcode工程给别人的话就不能使用高版本了 还是说大佬以后会支持多种选择 可以选择还是采用原始的自己编译.a的方式
不好意思 请问一下最近打包遇到了 il2cpp redifination xxxxx的报错,il2cpp生成的ZeusCore_Attr.cpp 定义了两个同样的方法ByteBufferAllocator_t0E319F952878FBAB0B83EF60D2A5BC7C3ED5F5C8_CustomAttributesCacheGenerator_A
反编译自己的dll之后发现dll中自动生成了名字相同的变量
private int A;
private byte[] A;,
而我的代码在编译成dll之前是一个访问器
public int a {get;protected set;}
public byte[] b {get;protected set;} 并没有修改的空间,且原生il2cpp并不会造成打包报错。
请问这种情况怎么解决?(unity版本2020.3.33,hybrid_unitypackage 已经更到最新)
只要在热更代码里面调用UniTask 函数函数就会闪退
例如下面的这个非常简单的代码:
public async UniTask UniTaskTest()
{
await Task.Delay(1000);
Debug.LogError("UnitTask");
}
之前使用的hybirdclr版本是3.4.2, unity 版本是2022.3.7.f1c1 是没有问题,
升级unity到3.17f1c1之后,使用原来的hybirdclr版本(3.4.2)会出编译错误的问题,就将hybirdclr升级到了最新版本,
打包出来之后,游戏走到热更代码中unitask相关代码的时候就会闪退了,在IOS和Android上都会发生,
我创建了一个复现工程使用下面的代码作为热更代码
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using UnityEngine;
public class GameApp
{
private static GameApp _instance;
public static GameApp Instance
{
get
{
if (null == _instance)
{
_instance = new GameApp();
}
return _instance;
}
}
//UniTask测试代码,执行到这里必定崩溃
public async UniTask UniTaskTest()
{
await Task.Delay(1000);
Debug.LogError("UnitTask");
}
//游戏热更代码入口
public static void Entrance(object[] objects)
{
Debug.Log("Enter Entrance");
Debug.Log("Start UniTaskTest");
Instance.UniTaskTest().Forget();
}
}
由于默认打包的是放在HyBridCLRData 中的。如果要放在自己的资源管理中,需要手动操作一次复制。所以希望增加一个接口的实现Post 调用。方便开发者在不修改源码的情况下自动调用自定义的讲aot 代码dll 复制到自己的资源管理中.
We have some structs where the method bridge generation code was calculating a different size than the runtime code was. So we were getting some missing method bridge errors at runtime when we ran the hot loaded code. The problem was that the structs have FieldOffset attributes and ExplicitLayout, but the code in ValueTypeSizeAligmentCalculator.cs wasn’t accounting for it. The struct’s TypeDef had a null ClassLayout so it never entered the section of code that checks the FieldOffset.
To work around this, I removed the check for (sa != null) so that the size calculation code will check the FieldOffset value even if the ClassLayout is null.
Here are the details asked for in the bug report template:
Unity version: 2021.3.1f1
Operating system: Windows 10
Target: Windows
Version of com.focus-creative-games.hybridclr_unity: 0.9.0
Version of hybridclr and il2cpp_plus: Version that goes with the 0.9.0 package, from about a month ago. However, the code where I found the problem is the same in the latest versions of HybridCLR.
Code location:
com.focus-creative-games.hybridclr_unity\Editor\ABI\ValueTypeSizeAligmentCalculator.cs
SizeAndAligmentOfStruct function
Line 78
Please let me know if I can provide any more information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.