Unity study notes - hot update related

foreword

I have always wondered why Unity can’t be hot-updated directly, and I have to use lua or IlRuntime to get these virtual machines around. Until Hybird appeared, I wondered why HyBird could, so I learned more about it.

explain

The first thing we should understand is how the code runs on the machine to work. We all know that the computer can only understand 0 and 1, but it is impossible for us to write these codes with 01, so there are various language aids. We work.

So it can be roughly understood that the overall work part can be divided into two parts: compile time and runtime

It is easy to understand when compiling is the process of our code writing, but this process is diverse. After all, the platform is updated relatively quickly, and various APIs are also emerging in an endless stream. If you don’t pay attention, it will be outdated. This part is mainly to solve the difference in system software. Yes, of course, this process can also be handed over to the runtime, but in this case, the workload will be too large and it is not very realistic

Then at runtime, our code is converted into machine code. When the machine code runs on the memory, it is when the machine is working. Generally speaking, there are only so many instructions in the machine code. In this process, the CPU hardware difference is resolved.

Then we also need to understand how Unity is cross-platform. Unity uses C#. C# itself does not have the ability to cross-platform. It can only run on the windows platform. It is Mono and IL2cpp. Mono has basically been abandoned by Unity. Without copyright, it is not as efficient as IL2cpp.

Mono is based on Just in time, c# language is compiled into CIL, and then run on Mono, Mono has its own runtime, and then runs to the machine with the help of runtime

IL2cpp is based on Ahead of time. Due to the limitation of the IOS platform, it does not support JIT, so it can only use the AOT method. After the C# language is compiled into IL, it runs on the IL2cpp platform, and then converted into cpp language, taking advantage of the advantages of cpp language , the efficiency is naturally higher, and at the same time, your own VM is also assisting in the work

LUA: Lua is a scripting language written in C. It reads the code written in Lua at runtime. When interpreting Lua bytecode (Lua's own instructions), it is not translated into machine code, but interpreted using C code. Open up a special memory space, and no new code will be executed. What is executed is a Lua virtual machine, a virtual machine written in C,

ILRuntime

 HuaTuo:

HybridCLR expands the il2cpp runtime and transforms it from an AOT runtime to a 'AOT + interpreter' dual-engine hybrid runtime, which perfectly supports the seamless running of dynamically loaded dlls in interpreted mode on iOS, a platform that prohibits JIT. . As shown below:

Guess you like

Origin blog.csdn.net/qq_55042292/article/details/125890156