当前位置:网站首页>Unity Huatuo hot update environment installation and sample project

Unity Huatuo hot update environment installation and sample project

2022-07-27 02:04:00 Clank's game stack

In the last section we analyzed huatuo Principle and advantages of , I believe you can't wait to experience huatuo Hot update , In this section, we will install huatuo Development environment of , Then run the sample project , To experience huatuo Make a hot update .

Here is a Game development communication group You can learn and communicate together

huatuo Hot development environment installation

Use huatuo Before , Let's prepare the development environment first ,Unity edition , Official huatuo The version uses unity 2020.3.33f1 This version of , It is suggested that you also use this version . Install well visual studio 2019 development environment , And install C/C++ A collection of development tools . install Unity When , We must check Windows IL2CPP, It's convenient for us to wait Windows On platform testing . Next download huatuo Related codes , huatuo It is mainly the transformation IL2CPP, So the dependent code base is as follows :

  1. huatuo The core code base , Responsible for instruction conversion , Explain to perform , Source download
  2. IL2CPP_huatuo: huatuo in the light of IL2CPP Modification and modification of , Source download
  3. huatuo-tutorial: huatuo Hot update example project , Source download ;

When the download is complete , You will receive 3 Source package , As shown in the figure 1.2-1:

chart 1.2-1

decompression huatuo Source code package of the project , decompression il2cpp_huatuo Project source code package . After decompressing , take huatuo Project subfolders ”huatuo”, Copied to the il2cpp_huatuo Project libil2cpp Under the table of contents . Pictured 1.2-2 Shown :

chart 1.2-2

Get ready libil2cpp Of huatuo After environment , Let's put this folder ”libil2cpp” copy to Unity Engine IL2CPP In the corresponding directory , Before copying , Remember to back up the original . Pictured 1.2-3,Unity Editor 2020.3.33 il2cpp Medium libil2cpp.

chart 1.2-3

Here we are huatuo The development environment is ready .

function huatuo Hot example project

Huatuo After the development environment is installed , Next, we can run the instance project , The example project is very simple , We unzip the code package huatuo_trial, Unpack and use Unity 2020.3.33 Open this project , The directory structure of the project is shown in the figure 1.2-4:

chart 1.2-4

chart 1.2-5

Enter folder ”HuatuoData” after , function init_local_il2cpp_data Script , And that creates Localil2cppData Folder .

chart 1.2-6

Next we use Unity open huatuo Examples of projects , When testing hot updates , First configure the basic configuration of the project ( Of course, the sample project has been configured , But we should pay attention to our own projects ) Pictured 1.2-7.

chart 1.2-7

because huatuo Is based on IL2CPP To extend interpretation execution IL Of .dll. At this time, we need to split some parts that may be hotter , Use here unity Of ADF Mechanism , For every one created .asmdef file ,Unity Will generate a new one for you .net Project engineering , The benefits of this can be divided into functions to make the code hotter ( Such as the hall + Sub game , Each sub game can be divided into corresponding .dll), At the same time, compile by function , Not to modify the function A Your code requires all projects to be compiled , As a result, the later development is slower and slower .

chart 1.2-8

In this way, we have divided the project into several projects by function , Then you can package out each project based on IL Of .dll library . In this way, we can aim at the hotter .dll To load .

When we officially started the project , You can put these .dll utilize AOT Compile together , If you want to heat up a library , First determine whether there is the latest .dll, If so, you can load this at runtime , If not, run the default AOT The later code is ok ( Get better AOT Level of performance , After all, explain and implement IL Instructions , Performance also has overhead ).

Next, let's try the hot update , The example project extends a menu , You can package all projects IL Instruction code .dll, This menu expands to ”Huatuo”---> “CompileDall”, In this way, we can put all the current projects .dll Type it all out , Whether you are hot or not . Generated IL Of .dll after , If we put these .dll Package into resource package , Deploy to server , Load from the resource package IL Code to IL2CPP VM You can achieve hotter , So there is another menu ”Huatuo”---> “BuildBundles”, They will .dll play ab package .( Here is an example , It's not mandatory , Different projects can be customized by yourself , I'll teach myself the strategy when making the framework later , In this case .dll Pack to common ab In bag , Let's see common ab Bag mainifest.)

chart 1.2-9

Next, test the hot update , Compile the complete .dll And packaging ab After package , We released a win We add it 1.0,build After you come out , Run the following :

chart 1.2-10

Printed in the first edition , Yes ######, Next I'll remove this ######, Then recompile , pack Hotfix.dll New arrival common ab package , And directly copy common ab Package to the packed StreammingAssets Next , Pictured :

chart 1.2-10

Today's sharing is here , Pay attention to our , We will continue to update next huatuo Hotter series of tutorials .

Notice of next section : huatuo Hot example project source code analysis

原网站

版权声明
本文为[Clank's game stack]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207180337543289.html