Unity3D hot updates LuaFramework articles [08] - Principle and thermal hot update server to build more who stole my hot update? Mono, JIT, iOS

Foreword

Bedding front for so long, finally began to write hot update.

Unity game hot update contains two aspects, one is to update the resource, a script is updated.

Unity Resources updates are already supported in the major platform also can be used. The heat script updates in iOS platform is not allowed (except Lua).

In order for a set of code can support more heat in each platform, the game business logic of a comprehensive Lua is a workaround. This is also ToLua's doing.

About Unity relationship platform with more heat can read Chen Jiadong Gangster article: Who stole my hot update? Mono, JIT, iOS

 

First, the principle of hot update

1, simple to understand hot update

   There are two mobile phone App are updated.

  The first is the full amount of the update. App updates every time, developers need to upload a complete package (apk, ipa) the distribution platform, and users need to download a complete re-install new software packages. It is very user friendly, more friendly to developers.

  Because the developer uploaded to the platform, the platform will have to wait a long review, in particular the iOS platform (as short as two days or as long as ten and a half), it is the impact version of the game plan.

  Therefore, the second update on the way out.

  The second is an incremental update, each update, developers upload content of this update to the resource server, the user's App client only updated with this new content on-line, without having to re-download App.

  It appears to be very perfect way, and the tour is a mature operation at the end, but in such a way because the update content is not controlled, by Apple to prohibit the (Lua is a hole in Apple's stay).

2, hot update Detailed principles

( Because I personally understand this framework is also limited to the use phase, and not well its principles. In order to avoid misleading, are directly learn when I look at this article for the framework to explain the principles of direct reference to this over.)

Original link: https://zhuanlan.zhihu.com/p/21386682

 The dividing line between the content of the following two references are:


 Shown, Unity3D heat update involves three directories below.

                                                      FIG update process heat

Game Resource Directory : Unity3D file which contains the project StreamingAssets folder. After installing the game, these files will be copied verbatim to a specific file on the target machine folder, file folder different platforms different, as shown below (figure to windows platform, for example)

Mac OS或Windows:Application.dataPath + "/StreamingAssets";
IOS: Application.dataPath + "/Raw";
Android:jar:file://" + Application.dataPath + "!/assets/";

Data Directory : As the "Game Resource Directory" on Android and IOS is read-only, can not download online resources inside, so it is necessary to establish a "data directory", the directory is readable and writable. After the first time you open the game, the program content "game resource directory" copy to "data directory" (Step 1, this step only once, the next time the game is not open copy). During the game to load resources, are available from the "Data Catalog", unpacking (step 3). Under different platforms, "Data Catalog" address is different, LuaFramework is defined as follows:

Android or IOS: Application.persistentDataPath + " / LuaFramework " 
: Mac OS or Windows: c / LuaFramework / 
debug mode: Application.dataPath + " / StreamingAssets / "
Note: "LuaFramework" and "StreamingAssets" default value determined by the configuration, where

Network resource address : storage resource URLs game after the game is turned on, the program will download some updated files from the network resources to address data directory.

These directories contain different versions of resource files, as well as for files.txt version control. Files.txt content as shown below, which store the name of the resource file and md5 code. The program will be downloaded files.txt on "network address resource", then the md5 code "Data Directory" file compare, update the file has changed (step 2).

 files.txt

Update code defines hot LuaFramework in Assets \ LuaFramework \ Scripts \ Manager \ GameManager.cs, may need a little change when used in real projects. 


 

  Personal understanding:

  Game Resource Directory:  is the game's installation directory. If you are running directly in Unity, it should mean that Assset / StreamingAssets directory;

  If the program is packaged into exe, exe program should be in a directory (guess, did not verify)

  Data Directory: Because the game resource directory is not writable, so the program has opened up an additional directory can read and write, is the data directory.

  Network resource address: this says is that the server resource directory.

   

Second, the more heat build server

  Learn from above, to achieve hot update function, a storage server for network resources is a must. I am here to do the selection Tomcat server (any server to provide network access to other services can be).

Download and install Tomcat

  1) Download Tomcat

  Version: Tomcat9.0 windows platform 64-bit version of Download: https://tomcat.apache.org/download-90.cgi

  

  2) Download the JDK

  jdk version 1.8 or above (according to this version of Tomcat demand, if you use other versions of Tomcat, you may need another version of jdk)

  Download: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  3) environment variable configuration

  After downloading Tomcat, without having to install, unzip to the specified directory.

  After JDK download, the installation program until the end.

  In order for Tomcat to run properly, you need to configure the environment variables, I configured the following four.

  Riga two user variables:

  JAVA_HOME:F:\ProgramsDirectory\Java\jdk1.8

  CATALINA_HOME: I:\apache-tomcat-9.0.22

  System variables Path Lane add these two directories:

  F:\ProgramsDirectory\Java\jdk1.8\bin

  I:\apache-tomcat-9.0.22\bin

  Please refer to their actual catalog to be adjusted here does not provide detailed configuration method, this is not my standard with France. Have questions, please take advantage of the search.

  4) running Tomcat

  环境变量配置完成之后,执行apache-tomcat-9.0.22\bin目录下的startup.bat文件。

  看到http-nio-8080之类的字样,表示服务器已经运行,如下图。

  

  (我这里不知道为啥乱码了,明明没有中文及空格等不合规目录,不过不影响使用)

  在浏览器里输入:http://localhost:8080/ ,看到如下页面,表示Tomcat启动成功。

  

  

  本篇就讲到这里,后边就要讲怎么实现代码及资源更新了。

  晚安!

Guess you like

Origin www.cnblogs.com/imteach/p/11257275.html