当前位置:网站首页>Unity Huatuo revolutionary hot update series [1]
Unity Huatuo revolutionary hot update series [1]
2022-07-27 02:05:00 【Clank's game stack】
1.1 Why NB?huatuo revolution Unity Hot update
lately huatuo( Hua Tuo ) Hot update solutions are hot unity Development circle , At first, I thought it was hot to update , Is not a built-in script interpreter + Script language development , Such as xLua, ILRuntime, puerts.Huatuo What tricks can you play , Why is it so NB, It has attracted the attention and praise of so many programmers ? With these questions, I read them in detail huatuo Information , Read the sample project +huatuo Source code , I also instantly became a ” Tuofen ”. Next, update a series of text tutorials + Video tutorials to explain in detail huatuo Hot update .
Here's one Game development communication group , I hope you can go in and learn and communicate together
To master huatuo Hot update , Let's first understand some underlying concepts and principles , Understanding these is mastering huatuo The key to . In this section, I will start with 3 Explain in detail in four aspects huatuo Hot update solutions :
- il2cpp What is it? ? AOT What is it? ?
- huatuo The technical principle of hot renewal ;
- huatuo Revolutionary advantages of the hotter solution ;
il2cpp What is it? ? AOT What is it? ?
Say il2cpp Before , Let's talk about it first. mono, stay mono Before ,C# Good as it is , But only in windows Used on the family platform , That's it C# And Java Can't compare . So Microsoft company to ECMA The application will C# As a standard . stay 2001 year 12 month ,ECMA Released ECMA-334 C# language norm .C# stay 2003 Become a ISO standard (ISO/IEC 23270). It means that as long as you abide by CLI(Common Language Infrastructure), Third parties can implement any language to .Net Above the platform . With CLI Standards for ,Mono It was born , The goal of the project is to create a series of products that meet ECMA standard (Ecma-334 and Ecma-335) Of .NET Tools , Include C# Compiler and general language architecture . Microsoft .NET Framework( Common language operation platform ) Different ,Mono Projects can not only run on Windows On the system , It can also run on Linux,FreeBSD,Unix,OS X and Solaris, Even some game platforms , for example :Playstation 3,Wii or XBox 360 above .Mono bring C# This language is relative to Microsoft .Net With good cross platform ability .
.Net Framework Runtime library Mono Use your own Mono VM. add C# Its own rapid and friendly development ability , Eventually making Unity At the beginning of its creation, the team decided to Mono,C# As its core .
Next comes an important concept ”IL“.IL The full name is Intermediate Language, Many times you will see CIL(Common Intermediate Language, Especially in .Net Under the platform IL standard ). stay Unity in ,IL and CIL It means the same thing : It is a general language architecture and .NET Lower order of frame (lowest-level) Programming language . take .NET The language of the framework is compiled into CIL, Then assemble it into bytecode .CIL Similar to an object-oriented assembly language , And it's completely stack based , It runs in .net Virtual machine .
CLI When the standard comes out , There is another project :IL2CPP, hold IL Turn into static c++ Code file , Compiled into binary machine instructions by a local compiler . because C# Such high-level languages have mechanisms such as garbage collection , therefore IL Turn into static c++ After code , One more IL2CPP Of runtime(IL2CPP VM) To support these high-level language features . adopt IL2CPP technology , We IL Code to local machine code , Get good performance .Unity It's also using this technology , use unity Developed C# The code can go through .net Turn into IL Code , Re pass IL2CPP Turn to static c++ file , Then compile it into local machine code to run . Why? Unity use IL2CPP Well ? The main reasons are :
a:Mono VM Migrate on various platforms , Maintenance is time consuming , Sometimes it's even impossible to complete .
b: Mono Version authorization is restricted , in IL2CPP,IL2CPP VM This set of completely self-developed components , It solves the authorization problem .
c: Improve operational efficiency , Switch to IL2CPP in the future , The program is compiled into hardware target machine instructions , Improve operation efficiency 1.5-2.0 times .
Unity be based on IL2CPP Architecture principle of , Pictured 1.1-1 Shown :

chart 1.1-1
Unity IL2CPP Operation diagram
The last concept AOT(Ahead of time),AOT technology It refers to the direct transformation of high-level development language into traditional compiled programming language ( Such as C/C++), Then compile it into machine instruction code and run it on hardware .IL2CPP Can be a AOT technology .
huatuo The technical principle of hot renewal
After bedding IL2CPP,AOT Wait for the concept , Next, let's talk about huatuo 了 . From the figure 1.1-1 You know Unity The final packaging run is :AOT( Local machine instruction execution )+, IL2CPP VM( Provide basic service support , Such as gc). about IL2CPP In terms of the underlying operation mode , When it's running, it's Data memory object + Code machine instructions Two parts .huatuo To be hot is to expand IL2CPP VM Service for , Let it be used Original data memory object Under the circumstances , Expanded Explain to perform IL Code The function of ( Note the use of ” Original data memory object ” Very important ). Give Way IL2CPP The operation mode of is changed to : Data memory object +AOT Code machine instructions +Interpreter IL Instruction interpretation execution Of 3 Parts of .huatuo When it's hotter , We just need to use Unity ADF(asmdef, Assembly definition file ) The mechanism of , Give Way Unity Compile a part separately IL The directive .dll. When it is hotter ,IL2CPP_huatuo You can load IL Instructions .dll, from IL2CPP_huatuo To explain the execution . such AOT Pattern +huatuo IL Instruction interpretation execution (Interpreter) Give Way huatuo It can have the function of hot update . meanwhile huatuo Explain that execution uses original AOT Data memory object , therefore huatuo The hot update will not have the interface export required by other hot update schemes , A series of problems such as cross domain calls . Let developers without any special treatment , Direct use of ordinary unity Development technology can achieve hot update . Because it can be used directly AOT Data memory object , Memory footprint , The performance will be better . With these advantages ( No need to do any code processing can achieve hotter ), It is no wonder that Unity Developers are cheering , Because they can finally lose xLua, ILRuntime Stupid and heavy shell , Solve problems directly from the bottom . So I think the future huatuo It's going to be Unity Hot mainstream solutions .
huatuo Revolutionary advantages of hotter
After analyzing the principle , Let's see huatuo Revolutionary advantages :
huatuo The first 1 One advantage is based on AOT( Local machine code execution )+Interpreter (IL Explain to perform ) Use the same Memory data object , There is no problem of cross domain access . Let's get xLua or ILRuntime Take the heat change scheme as an example , There is a principle in these schemes , Try to minimize and Unity C# Layer interaction , But this kind of interaction is unavoidable and large , For example, we need to access it in the logic code Unity C# Of GameObject Object data , Finally, when running ,GameObject Will be in AOT Native memory data structure object in mode . because xLua or ILRuntime Have your own virtual machine , Therefore, you cannot directly access native GameObject Data objects , It is often necessary to package the data in the access as a function , This greatly increases the performance overhead . and huatuo Is in IL2CPP Interpretation execution in mode , You can directly access native data objects .
huatuo The first 2 One advantage is that our logic code is updated (1.0 Version to 2.0 edition ), If you release a new version 2.0( Reinstall the new version of app), You can directly update the logic , Use it directly AOT Compile it , No need to explain the implementation , In order to gain AOT Performance of . And based on xLua, ILRuntime Hot program development code (1.0 Version to 2.0 edition ), Even if the user reinstalls 2.0 After the client , Or explain and execute , The performance of the new version cannot be achieved AOT Performance level of .
huatuo The first 3 One advantage is that compared with traditional Lua or ILRuntime Thermogeny , He can update any part of the code . Don't look like Lua or ILRuntime equally , Heat distribution code + Framework code , The framework code has bug It can't be hotter .
With these revolutionary advantages , You have no reason not to pay attention + Use huatuo.
Today's sharing is here , Pay attention to our , There will continue to be huatuo Hotter series of tutorials .
Notice of next section : huatuo Solution source code structure and project practice
边栏推荐
- 解决方案:读取两个文件夹里不同名的文件,处理映射不对应的文件
- MySQL single table query exercise
- Text to image论文精读DF-GAN:A Simple and Effective Baseline for Text-to-Image Synthesis一种简单有效的文本生成图像基准模型
- Difference between fat AP and thin AP & advantages and disadvantages of networking
- 为啥不建议使用Select *
- [FPGA tutorial case 28] one of DDS direct digital frequency synthesizers based on FPGA -- principle introduction
- Enumerated valueof() method stepping on the pit
- (codeforce 807div2)C. Mark and his unfinished essay (thinking)
- Machine learning exercise 7 - K-means and PCA (principal component analysis)
- Share 29 chrome plug-ins, and there is always one for you
猜你喜欢

Docker高级篇之Mysql主从复制、Redis集群扩容缩容配置案例详解

MySQL多表查询

Homework 1-4 learning notes

The gradient descent method and Newton method are used to calculate the open radical

Codeforce problem 908 D. new year and arbitrary arrangement (probability DP)

count(*)为什么很慢

MySQL备份恢复

Text to image论文精读RAT-GAN:文本到图像合成中的递归仿射变换 Recurrent Affine Transformation for Text-to-image Synthesis

Use ECs and OSS to set up personal network disk

Merge sort (recursive and non recursive writing)
随机推荐
Removal and addition of reference types in template and generic programming
MySQL多表查询
GAN的训练技巧:炼丹师养成计划 ——生成式对抗网络训练、调参和改进
Machine learning exercise 6 - Support Vector Machines
In regular expressions (?: pattern), (?! pattern), (? < =pattern) and (?
选择器的使用语法与场景以及背景图片大小、文字盒子阴影、过度效果的使用方法
[translation] reduced precision in tensorrt
STM32_HAL_SUMMARY_NOTE
ACM模式输入输出练习
索引失效原理讲解及其常见情况
R分数复现 R-precision评估指标定量 文本生成图像R分数定量实验全流程复现(R-precision)定量评价实验踩坑避坑流程
Text to image论文精读GR-GAN:逐步细化文本到图像生成 GRADUAL REFINEMENT TEXT-TO-IMAGE GENERATION
Mysql数据库-面试题
Codeforce problem 908 D. new year and arbitrary arrangement (probability DP)
Difference between fat AP and thin AP & advantages and disadvantages of networking
[polymorphism] the detailed introduction of polymorphism is simple and easy to understand
Ubuntu12.10 installing mysql5.5 (III)
STM32 HAL库串口(UART/USART)调试经验(一)——串口通信基础知识+HAL库代码理解
[cann training camp] enter media data processing 1
7.8 锐捷网络笔试