çŽ1幎åã Unityã§ã®ã¹ã¯ãªããäœæã®æªæ¥ã«ã€ããŠæžããŸããã æ°ããIL2CPPã¹ã¯ãªããã£ã³ã°ãã¯ãããžãŒã¯ãé«æ§èœã§ããŒã¿ãã«ãªä»®æ³ãã·ã³ããšã³ãžã³ã«æäŸããããšã«ãªã£ãŠããŸãã 1æãIL2CPPã䜿çšããæåã®64ãããiOSãã©ãããã©ãŒã ããªãªãŒã¹ããŸããã Unity 5ã®ãªãªãŒã¹ã§ãå¥ã®ãã©ãããã©ãŒã ãç»å ŽããŸãã-WebGL ã 巚倧ãªãŠãŒã¶ãŒã³ãã¥ããã£ã®ãµããŒãã«ãããIL2CPPã®å€ãã®ããããšã¢ããããŒãããªãªãŒã¹ããã³ã³ãã€ã©ãåŸã ã«æé©åããç°å¢ã®ããã©ãŒãã³ã¹ãåäžãããŸããã
ãããŸã§ã®éãIL2CPPã®æè¡ã®æ¹åãç¶ããŠãããIL2CPPã®ä»çµã¿ã«ã€ããŠã話ãã§ããã°ããããã§ãã ãã®ãããªãããã¯ã«é¢ããäžé£ã®èšäºãæžãäºå®ã§ãã
1.åºæ¬-ããŒã«ããããšã³ãã³ãã©ã€ã³åŒæ°ïŒãã®èšäºïŒã
2.çæãããã³ãŒãã®ãã¢ãŒã
3.çæãããã³ãŒãããããã°ããããã®ãã³ãã
4.ã¡ãœããåŒã³åºãïŒéåžžã®ã¡ãœãããä»®æ³ã¡ãœãããªã©ã
5.äžè¬çãªäº€æã®å®è£ ã
6. P /åããã³ã¡ãœããã®ã©ãããŒãåŒã³åºããŸãã
7.ã¬ããŒãžã³ã¬ã¯ã¿ãŒã®çµ±åã
8.ãã¬ãŒã ã¯ãŒã¯ã®ãã¹ããšé©çšã
ãããã®èšäºã§ã¯ãIL2CPPã®å®è£ ã®ããã€ãã®æ©èœã«ã€ããŠèª¬æããŸãã ãã®æ å ±ã圹ã«ç«ã€ããšãé¡ã£ãŠããŸãã
IL2CPPãšã¯äœã§ããïŒ
IL2CPPãã¯ãããžãŒã¯ã2ã€ã®éšåã§æ§æãããŠããŸãã
â¢Ahead-of-timeïŒAOTïŒã³ã³ãã€ã©ã
â¢ä»®æ³ãã·ã³ããµããŒãããå®è¡å¯èœã©ã€ãã©ãªã
AOTã³ã³ãã€ã©ã¯ã.NETã³ã³ãã€ã©ããã®äžéèšèªïŒILïŒãC ++ãœãŒã¹ã³ãŒãã«å€æããŸãã å®è¡å¯èœã©ã€ãã©ãªã¯ããµãŒãã¹ãšæœè±¡åïŒã¬ããŒãžã³ã¬ã¯ã¿ãŒãªã©ïŒãã¹ããªãŒã ãšãã¡ã€ã«ãžã®ã¯ãã¹ãã©ãããã©ãŒã ã¢ã¯ã»ã¹ãããã³å éšåŒã³åºãïŒãããŒãžããŒã¿æ§é ãçŽæ¥å€æŽããã¢ã³ãããŒãžã³ãŒãïŒãå®è£ ããæ¹æ³ãæäŸããŸãã
AOTã³ã³ãã€ã©
IL2CPP AOTã³ã³ãã€ã©ã¯ãil2cpp.exeãšåŒã°ããŸãã Windowsã§ã¯Editor \ Data \ il2cppãã£ã¬ã¯ããªã«ãOS Xã§ã¯Unityã€ã³ã¹ããŒã«å Žæã®Contents / Frameworks / il2cpp / buildãã£ã¬ã¯ããªã«ãããŸãã il2cpp.exeãŠãŒãã£ãªãã£ã¯å®å šã«CïŒã§èšè¿°ããã.NETããã³Monoã³ã³ãã€ã©ã䜿çšããŠã³ã³ãã€ã«ãããŸãã
ãã®ãŠãŒãã£ãªãã£ã¯ãUnityã«å梱ãããŠããMonoã³ã³ãã€ã©ã«ãã£ãŠã³ã³ãã€ã«ããããããŒãžã¢ã»ã³ããªãåãåããç¹å®ã®ãã©ãããã©ãŒã ã®C ++ã³ã³ãã€ã©ã«æž¡ãC ++ã³ãŒããçæããŸãã
IL2CPPããŒã«ãããã¯ã次ã®ããã«æŠç¥çã«è¡šãããšãã§ããŸãã
å®è¡å¯èœã©ã€ãã©ãª
IL2CPPãã¯ãããžãŒã®2çªç®ã®éšåã¯ãä»®æ³ãã·ã³ããµããŒãããå®è¡å¯èœã©ã€ãã©ãªã§ãã ãã®ã©ã€ãã©ãªã¯ã»ãŒå®å šã«C ++ã§èšè¿°ããïŒãã©ãããã©ãŒã ã³ãŒãã¯ãããããããŸãããç§ãã¡ã®éã«ã¯ãã®ãŸãŸã«ããŠãããŸãïŒãlibil2cppãšåŒã°ããŸãã ãã¬ãŒã€ãŒã®å®è¡å¯èœãã¡ã€ã«ã«é¢é£ä»ããããéçã©ã€ãã©ãªã®åœ¢åŒã§æäŸããããã®ã·ã³ãã«ããšç§»æ€æ§ã¯IL2CPPãã¯ãããžãŒã®äž»ãªå©ç¹ã®äžéšã§ãã
Unityã«ä»å±ã®ããããŒãã¡ã€ã«ãèŠããšãlibil2cppã³ãŒããæŽçããããæ確ãªã¢ã€ãã¢ãåŸãããšãã§ããŸãïŒãšãã£ã¿ãŒã®\ Data \ PlaybackEngines \ webglsupport \ BuildTools \ Libraries \ libil2cpp \ includeãã£ã¬ã¯ããªããŸãã¯Contents / Frameworks /ãã£ã¬ã¯ããªã«ãããŸãïŒ il2cpp / libil2cpp-OS Xã§ïŒã ããšãã°ãil2cpp.exeã«ãã£ãŠçæãããC ++ã³ãŒããšlibil2cppç°å¢ã®éã®ã€ã³ã¿ãŒãã§ã€ã¹ã¯ãcodegen / il2cpp-codegen.hããããŒãã¡ã€ã«ã«ãããŸãã
ç°å¢ã®éèŠãªèŠçŽ ã®1ã€ã¯ãã¬ããŒãžã³ã¬ã¯ã¿ãŒã§ãã Unity 5ã«ã¯ãBoehm-Demers-Weiserã¬ããŒãžã³ã¬ã¯ã¿ãŒã§ããlibgcãä»å±ããŠããŸãã ãã ããlibil2cppã¯ä»ã®ãã«ããŒããµããŒãããŠããŸãã ããšãã°ãCoreCLRã¹ã€ãŒãã®ãªãŒãã³ãœãŒã¹ã³ã³ãã€ã©ã§ããMicrosoft GCãšã®çµ±åãæ€èšããŠããŸãã 次ã®èšäºã®ããããã§ãããã«ã€ããŠããã«è©³ãã説æããŸãã
il2cpp.exeã®å®è¡æ¹æ³
äŸãèŠãŠã¿ãŸãããã ãããè¡ãã«ã¯ãWindowsäžã®Unity 5.0.1ã§æ°ãã空ã®ãããžã§ã¯ããäœæããŸãã å°ãªããšã1ã€ã®ãŠãŒã¶ãŒã¹ã¯ãªãããããããã«ãã¡ã€ã³ã«ã¡ã©ã«åçŽãªMonoBehaviourã³ã³ããŒãã³ããè¿œå ããŸãã
WebGLãã©ãããã©ãŒã çšã«ãã«ãããå ŽåãProcess Explorerã䜿çšããŠãil2cpp.exeãå®è¡ããã³ãã³ãã確èªã§ããŸãã
"C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\bin\mono.exe" "C:\Program Files\Unity\Editor\Data\il2cpp/il2cpp.exe" --copy-level=None --enable-generic-sharing --enable-unity-event-support --output-format=Compact --extra-types.file="C:\Program Files\Unity\Editor\Data\il2cpp\il2cpp_default_extra_types.txt" "C:\Users\Josh Peterson\Documents\IL2CPP Blog Example\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll" "C:\Users\Josh Peterson\Documents\IL2CPP Blog Example\Temp\StagingArea\Data\Managed\UnityEngine.UI.dll" "C:\Users\Josh Peterson\Documents\IL2CPP Blog Example\Temp\StagingArea\Data\il2cppOutput"
ããã¯ããªãé·ãè¡ãªã®ã§ãéšåçã«è§£æããŠã¿ãŸãããã Unityã¯æåã«ãã®å®è¡å¯èœãã¡ã€ã«ãå®è¡ããŸãã
ãCïŒ\ Program Files \ Unity \ Editor \ Data \ MonoBleedingEdge \ bin \ mono.exeã
次ã®åŒæ°ã¯ãil2cpp.exeãŠãŒãã£ãªãã£èªäœã§ãã
ãCïŒ\ Program Files \ Unity \ Editor \ Data \ il2cpp / il2cpp.exeã
æ®ãã®åŒæ°ã¯ãmono.exeã§ã¯ãªãil2cpp.exeã«æž¡ãããŸãã ããããèŠãŠã¿ãŸãããã ãŸããUnityã¯5ã€ã®il2cpp.exeãã©ã°ãæž¡ããŸãã
â¢-copy-level =ãªã
il2cpp.exeããçæãããC ++ã³ãŒããã¡ã€ã«ã®ç¹å¥ãªã³ããŒãå®è¡ããªãããšã瀺ããŸãã
â¢-enable-generic-sharing
ã³ãŒããšãã€ããªãã¡ã€ã«ã®ãµã€ãºãçž®å°ããŸãã ãã®ãã¡ãIL2CPPã§ãžã§ããªãã¯ã¡ãœãããå®è¡ããããã»ã¹ãå ¬éããŸãã
â¢-enable-unity-event-support
ãªãã¬ã¯ã·ã§ã³ã«ãã£ãŠããªã¬ãŒãããUnityã€ãã³ãã®æ£ããã³ãŒãçæãæäŸããŸãã
â¢-output-format =ã³ã³ãã¯ã
ååãšã¡ãœããã®æåæ°ãå°ãªã圢åŒã§C ++ã³ãŒããçæããŸãã äžéèšèªã®ååãä¿åãããŠããªãå Žåããã®ãããªã³ãŒãã¯ãããã°ãé£ãããªããŸãããC ++ã³ã³ãã€ã©ã解æããã³ãŒããå°ãªããŠæžããããã³ã³ãã€ã«ãé«éã«ãªããŸãã
â¢-extra-types.file = "CïŒ\ Program Files \ Unity \ Editor \ Data \ il2cpp \ il2cpp_default_extra_types.txt"
è¿œå ã®ã¿ã€ãã«æšæºã®ç©ºã®ãã¡ã€ã«ã䜿çšããŸãã Unityãããžã§ã¯ãã«è¿œå ã§ããã®ã§ãil2cpp.exeã¯å®è¡æã«äœæããããžã§ããªãã¯åãŸãã¯ã€ã³ããã¯ã¹ä»ãã®åãèªèããŸãããILã³ãŒãã§ã¯æå®ãããŸããã
il2cpp.exeã®ãã®äžé£ã®ã³ãã³ãã©ã€ã³åŒæ°ã¯ãŸã äžå®å®ã§ãããå°æ¥ã®ããŒãžã§ã³ã§å€æŽãããå¯èœæ§ãé«ãããšã«æ³šæããŠãã ããã
ãããã£ãŠãã³ãã³ãã©ã€ã³ã«ã¯2ã€ã®ãã¡ã€ã«ãš1ã€ã®ãã£ã¬ã¯ããªããããŸãã
â¢ãCïŒ\ Users \ Josh Peterson \ Documents \ IL2CPP Blog Example \ Temp \ StagingArea \ Data \ Managed \ Assembly-CSharp.dllã
â¢ãCïŒ\ Users \ Josh Peterson \ Documents \ IL2CPP Blog Example \ Temp \ StagingArea \ Data \ Managed \ UnityEngine.UI.dllã
â¢ãCïŒ\ Users \ Josh Peterson \ Documents \ IL2CPP Blog Example \ Temp \ StagingArea \ Data \ il2cppOutputã
il2cpp.exeãŠãŒãã£ãªãã£ã¯ãå€æããããã¹ãŠã®ILã¢ã»ã³ããªã®ãªã¹ããåãå ¥ããŸãã ç§ãã¡ã®å Žåãããã«ã¯åçŽãªMonoBehaviourã¹ã¯ãªãããAssembly-CSharp.dllããã³UnityEngine.UI.dllãå«ãŸããŸãã ããã§ã¯ãããã€ãã®ã¢ã»ã³ããªãæããã«æ¬ èœããŠããããšã«æ³šæããŠãã ããã æããã«ãç§ã®ã¹ã¯ãªããã¯UnityEngine.dllãåç §ããŠããŸããã€ãŸããå°ãªããšãmscorlib.dllãšãããããä»ã®ã¢ã»ã³ããªãå¿ èŠã§ãã ãããã圌ãã¯ã©ãã§ããïŒ å®éãã¢ã»ã³ããªã®è§£æ±ºã¯il2cpp.exeå ã§è¡ãããŸãã ãããã¯ã³ãã³ãã©ã€ã³ã§èšåã§ããŸãããããã¯ãªãã·ã§ã³ã§ãã Unityã¯ãã«ãŒãã¢ã»ã³ããªïŒä»ã®ã¢ã»ã³ããªãåç §ããªãïŒãæå®ããã ãã§ããããšãããããŸããã
il2cpp.exeã®æåŸã®ã³ãã³ãã©ã€ã³åŒæ°ã¯ãC ++ãã¡ã€ã«ãäœæããããã£ã¬ã¯ããªã§ãã èå³ãããå Žåã¯ãçæããããã¡ã€ã«ã«æ £ããããšãã§ããŸããã次ã®èšäºã§ãããã«ã€ããŠè©³ãã説æããŸãã ãã£ã¬ã¯ããªãéãåã«ãWebGLãã«ãèšå®ã§Development Playerãªãã·ã§ã³ãéžæããå¿ èŠããããŸãã ããã«ããã-output-format = CompactåŒæ°ãåé€ãããC ++ã³ãŒãã§ã®ååãšã¡ãœããåã®è¡šç€ºãæ¹åãããŸãã
Player Settings WebGLãŸãã¯iOSã§éãã§ã¿ãŠãã ããã il2cpp.exeã«æž¡ãããã³ãŒãçæã®ããŸããŸãªæ®µéãæ åœããããŸããŸãªã³ãã³ãã©ã€ã³ãã©ã¡ãŒã¿ãŒã衚瀺ãããŸãã ããšãã°ãWebGL Player Settingsã®Enable Exceptionsãã©ã¡ãŒã¿ãŒãFullã«èšå®ãããšã-emit-null-checksã-enable-stacktraceãããã³-enable-array-bounds-checkåŒæ°ãã³ãã³ãã©ã€ã³ã«è¿œå ãããŸãã
IL2CPPã¯äœãããªãã®ã§ããïŒ
ãã€ãã¹ããããšã§å€ãã®åé¡ãåé¿ããããšã«ãã1ã€ã®è€éãã«æ³šæãåèµ·ããããšæããŸãã IL2CPPã®äžã§æšæºCïŒã©ã€ãã©ãªãæžãæããããšããŸããã§ããã IL2CPPã䜿çšããŠUnityãããžã§ã¯ããäœæãããšãæšæºCïŒã©ã€ãã©ãªïŒmscorlib.dllãSystem.dllãªã©ïŒã®ãã¹ãŠã®ã³ãŒãã¯Monoã¹ã¯ãªããã³ãŒãã®æ£ç¢ºãªã³ããŒã§ãã
å€ãã®ãããžã§ã¯ãã§ããŸãæ©èœããŠãããããæšæºCïŒã©ã€ãã©ãªã®ã³ãŒãã䜿çšããŸãã ãããã£ãŠãã©ããã§ãšã©ãŒãçºçããå Žåãåé¡ã¯AOTã³ã³ãã€ã©ãŸãã¯å®è¡å¯èœã©ã€ãã©ãªã«ãããšç¢ºä¿¡ã§ããŸãã
IL2CPPã®éçºããã¹ããããã³ãªãªãŒã¹
1æã®IL2CPPããŒãžã§ã³4.6.1p5ã®æåã®å ¬åŒãªãªãŒã¹ä»¥æ¥ã6ã€ã®å®å šãªã¢ããããŒããš7ã€ã®ãããïŒUnity 4.6ããã³5.0çšïŒããªãªãŒã¹ãã100以äžã®ãšã©ãŒãä¿®æ£ããŸããã
ç¶ç¶çãªæé©åãä¿èšŒããããã«ã1ã€ã®ããŒãžã§ã³ã®ã³ãŒãã«åºã¥ããŠæŽæ°ãéçºããŠããŸãã åãªãªãŒã¹ã®åã«ããã¹ãŠã®å€æŽãç¹å®ã®ãªãªãŒã¹ãã©ã³ãã«è»¢éãããã¹ããå®æœããŠããã¹ãŠã®ãšã©ãŒãæ£åžžã«ä¿®æ£ããããã©ããã確èªããŸãã QAããŒã ãšãµã¹ãããã«ãšã³ãžãã¢ãªã³ã°ããŒã ã¯ããã®ããŒã¹ã§éçºãç¶ããããã«ããããåªåãæãããšã©ãŒã¯æ¯é±ä¿®æ£ãããŸãã
ç§ãã¡ã®ã³ãã¥ããã£ã¯ãå€ãã®æçšãªãšã©ãŒã¡ãã»ãŒãžãæäŸããããšã«ãããéåžžã«è²Žéãªæ¯æŽãæäŸããŠããŸããã IL2CPPã®ç¶ç¶çãªæ¹åã«åœ¹ç«ã€ãã¹ãŠã®ã¬ãã¥ãŒã«ã€ããŠããŠãŒã¶ãŒã«éåžžã«æè¬ããŠããŸãã
IL2CPPéçºè ã«ãšã£ãŠã¯ããã¹ããæåã«ãªããŸãã ç§ãã¡ã¯ãã°ãã°ããã¹ããéããŠéçºæè¡ãåºç€ãšããŠãããã³ãŒããå®å šã«ãã¹ããããŠããªãå Žåãå«ãããªã¯ãšã¹ããéä¿¡ããããšã¯ã»ãšãã©ãããŸããã ãã®æŠç¥ã¯ãæ確ãªå ¥åãšåºåãããIL2CPPã®ãããªãã¯ãããžãŒã«é©ããŠããŸãã ã€ãŸããçºçãããšã©ãŒã®å€§éšåã¯ãäºæããªãã·ã¹ãã åäœããããããç¹æ®ãªã±ãŒã¹ã§ãïŒ ããšãã° ã64ãããIntPtrã32ãããé åã€ã³ããã¯ã¹ãšããŠäœ¿çšãããšãC ++ã³ã³ãã€ã©ãšã©ãŒãçºçããå ŽåããããŸãïŒã ãããã£ãŠããã°ããã°ããç¹å®ããŠä¿®æ£ã§ããŸãã
ã³ãã¥ããã£ã®æ¯æŽã«ãããIL2CPPã®å®å®æ§ãšçç£æ§ãåžžã«åäžãããŠããŸãã
ç¶ã
次ã®èšäºã«é »ç¹ã«èšåããã®ã¯æãã§ãã ããããäŒãããã®ã§ããã1ã€ã®æçš¿ã«ã¯åãŸããŸããã 次åã¯ãil2cpp.exeã«ãã£ãŠçæãããã³ãŒãã詳ãã調ã¹ãC ++ã³ã³ãã€ã©ã®åäœã«ã€ããŠèª¬æããŸãã