错误
完整的il2cpp.exe报错:
Exception: D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe did not run properly!
Failed running "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe" --convert-to-cpp --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WebGL" --architecture="EmscriptenJavaScript" --configuration="Release" --outputpath="G:\计算机图形学\Ocean\BuildTest\UnderWaterSystem\Assets /../Temp/StagingArea/Data\Native\build.bc" --cachedirectory="G:\计算机图形学\Ocean\BuildTest\UnderWaterSystem\Assets\..\Library/il2cpp_cache" --compiler-flags="-Oz -DIL2CPP_EXCEPTION_DISABLED=1 " --emit-method-map --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AccessibilityModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AIModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AndroidJNIModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AnimationModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AssetBundleModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_AudioModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_ClothModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_CoreModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_CrashReportingModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_DirectorModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_DSPGraphModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_GameCenterModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_GridModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_HotReloadModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_ImageConversionModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_IMGUIModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_InputLegacyModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_InputModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_JSONSerializeModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_LocalizationModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_ParticleSystemModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_PerformanceReportingModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_Physics2DModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_PhysicsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_ProfilerModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_ScreenCaptureModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_SharedInternalsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_SpriteMaskModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_SpriteShapeModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_StreamingModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_SubstanceModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_SubsystemsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TerrainModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TerrainPhysicsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TextCoreModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TextRenderingModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TilemapModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_TLSModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UIElementsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UIModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UmbraModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UNETModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityAnalyticsModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityConnectModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityTestProtocolModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityWebRequestAssetBundleModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityWebRequestAudioModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityWebRequestModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityWebRequestTextureModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_UnityWebRequestWWWModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_VehiclesModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_VFXModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_VideoModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_VRModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_WebGLModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_WindModule_Dynamic.bc" --additional-libraries="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\lib\modules\WebGLSupport_XRModule_Dynamic.bc" --profiler-report --map-file-parser="D:/Program Files/Unity/2019.4.17f1c1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="G:/计算机图形学/Ocean/BuildTest/UnderWaterSystem/Temp/StagingArea/Data/Managed" --generatedcppdir="G:/计算机图形学/Ocean/BuildTest/UnderWaterSystem/Temp/StagingArea/Data/il2cppOutput"
stdout:
Building build.bc with EmscriptenToolChain
Output directory: G:\�����ͼ��ѧ\Ocean\BuildTest\UnderWaterSystem\Temp\StagingArea\Data\Native
Cache directory: G:\�����ͼ��ѧ\Ocean\BuildTest\UnderWaterSystem\Library\il2cpp_cache
ObjectFiles: 157 of which compiled: 0
Total compilation time: 101 milliseconds.
Response file: D:\Temp\_1842515173\response.rsp
Response file: D:\Temp\_1947989028\response.rsp
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe" -E "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc" -o "G:\�����ͼ��ѧ\Ocean\BuildTest\UnderWaterSystem\Library\il2cpp_cache\linkresult_6419C51A308275CB21C0D680D9EAABAD\build.bc" -s TOTAL_MEMORY=384MB -s DISABLE_EXCEPTION_CATCHING=0 -s WASM=0 -O3 "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AccessibilityModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AIModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AndroidJNIModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AnimationModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AssetBundleModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_AudioModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_ClothModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_CoreModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_CrashReportingModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_DirectorModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_DSPGraphModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_GameCenterModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_GridModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_HotReloadModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_ImageConversionModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_IMGUIModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_InputLegacyModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_InputModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_JSONSerializeModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_LocalizationModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_ParticleSystemModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_PerformanceReportingModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_Physics2DModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_PhysicsModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_ProfilerModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_ScreenCaptureModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_SharedInternalsModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_SpriteMaskModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_SpriteShapeModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_StreamingModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_SubstanceModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_SubsystemsModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\modules\WebGLSupport_TerrainModule_Dynamic.bc" "D:\Program Files\Unity\2019.4.17f1c1\Editor\Data\Playback<message truncated>
解决过程
分析上面问题。有个il2cpp.exe没跑对,它应该是最严重的问题,可能是它引发下面两个问题
看看论坛朋友们咋说
方法1:消除il2cpp缓存
下图这种消灭缓存的方法也试过了,不过一般针对unity突然抽风且代码无跨平台或其他问题的项目,不是本次的解决方法,第二个方法感觉也是拼运气的,和代码自身无关了(比较怀疑是项目里某些代码问题)
方法2:清除无用包或路径重定向 成功
如果按这位老哥说的,那我项目里唯一引入的外部包就是后处理,没它游戏运行不了,同时用重定向路径方法解决问题有可能,因为我的项目路径的确有中文(大意了...)
更换目录后仍然构建成功
可以看出不管是项目源文件还是构建后文件都不能有特殊字符(比如中文)
不过项目虽然成功构建到WebGL可喜可贺,但是大部分效果都丢了,UI上的字符也没了(怀疑是UI也是中文字符,无法解析),所以这次的结论是构建WebGL路径一定不能有中文,同时即使成功构建,很多效果会出现缺失甚至错误的情况(由于涉及到跨平台,很多规则不一样),后续会尝试解决一些错误,写一些新的踩坑文章。
IL2CPP
不过这次也引发对IL2CPP的好奇,它究竟在Unity转换到WebGL有什么作用
IL2CPP - Unity 手册 (unity3d.com)
从上面官方的解释看它是一种由 Unity 开发的脚本后端,可在为各种平台构建项目时替代 Mono。使用 IL2CPP 构建项目时,Unity 会在为所选平台创建本机二进制文件(例如 .exe、apk、.xap)之前将脚本和程序集内的 IL 代码转换为 C++。IL2CPP 的一些用途包括提高 Unity 项目的性能、安全性和平台兼容性。
Unity将来时:IL2CPP是什么? - 知乎 (zhihu.com) 2015
网上查到国内外介绍IL2CPP基本是2015年,看起来IL2CPP年代不小了,其也是为跨平台诞生的,和Mono是同级别概念,大概逻辑如下图【看博客原文去了解历史原因吧】,“C++是一门静态语言,这就意味着我们不能使用动态语言的那些酷炫特性。运行时生 成代码并执行肯定是不可能了。这就是Unity里面提到的所谓AOT(Ahead Of Time)编译而非JIT(Just In Time)编译。"博文里的这句话也可能就是本次构建错误的原因。
Mono
IL2CPP
Unity3D将来时:WebGL - 知乎 (zhihu.com) 2015
通过上述链接又了解了一套C++到js的过程
用Unity做游戏,你需要深入了解一下IL2CPP - 知乎 (zhihu.com) 2015
以上又是一个关键转换流程图
IL2CPP 深入讲解:代码生成之旅 - 知乎 (zhihu.com)
在Temp\StagingArea\Data\il2cppOutput下查看生成的C++(转换的C++文件非常多),Emscripten存放临时转换的js
在IL2CPP的后端处理中,通常会使用字节码剥离(byte code stripping)技术来减少可执行文件的尺寸
Unity深入讲解:方法调用介绍 - 知乎 (zhihu.com)
IL2CPP 深入讲解:泛型共享 - 知乎 (zhihu.com)
上述两个链接又介绍了IL2CPP相关优化
IL2CPP所覆盖的知识已经相当底层,日后学习一下这本书补一补底层知识
参考链接
构建和运行 WebGL 项目 - Unity 手册 (unity3d.com)
android - Unity Build - Exception: il2cpp.exe did not run properly - Stack Overflow
https://forum.unity.com/threads/exception-il2cpp-exe-did-not-run-properly.659323/
Build - IL2CPP errors - Please, how fix it? - Unity Forum
Error Building webgl: il2cpp.exe did not run properly! - Unity Forum