doc/unity/zhcn/performance/il2cpp.md
可用版本:>2.0.0
简单地说,il2cpp优化的思路是绕过 PInvoke直接通过il2cpp的接口访问C#,减少跨语言的消耗。最终使得性能表现大幅提升,详见il2cpp优化特性性能数据
Player Settings,添加Scripting Define Symbols: PUERTS_IL2CPP_OPTIMIZATION。Player Settings,添加Scripting Define Symbols: PUERTS_DISABLE_IL2CPP_OPTIMIZATION,在ios和webgl下默认关闭,添加Scripting Define Symbols: PUERTS_IL2CPP_OPTIMIZATION。Player Settings,添加Scripting Define Symbols: PUERTS_DISABLE_IL2CPP_OPTIMIZATION,在ios下默认关闭,添加Scripting Define Symbols: PUERTS_IL2CPP_OPTIMIZATION。如果你期待更高的性能,生成全量胶水代码:点击Unity的Tools/PuerTS/Generate For xIl2cpp mode (all in one with full wrapper)。
如果你期待更小的代码量,仅生成基于反射的胶水代码:点击Unity的Tools/PuerTS/Generate For xIl2cpp mode (all in one without wrapper)。
你的Unity.app/Contents/il2cpp/external/下找到缺失的内容,复制到iosbuild目录/Libraries/external/即可ReentrantLock is ambigious
在2022常见。解决办法:修改/Applications/Unity/Hub/Editor/2022.3.47f1c1/PlaybackEngines/iOSSupport/il2cpp/libil2cpp/il2cpp-config.h (根据你安装的unity的实际路径)
在#pragma once后加入宏定义:
#pragma once
#define BASELIB_INLINE_NAMESPACE il2cpp_baselib //this line fix 'ReentrantLock is ambigious'
#include <string.h>