Hot update

What is hot update?
Non-stop updates, real-time updates. HotUpdateHotFix
Unity is needed to restart the APP
real hot update without restarting do update

Why do hot update?
Improve the user experience (to save traffic, time, degree of operation), in the form of a patch, do not repeat players download the game, you can make hot fixes to the game.

How do hot update? unity3d hot update method?
Android heat applied updates:
1. code is compiled to be executed for the library file Assembly dll dynamic link library.
Then Unity by reflection manner loaded packetized dll files and execute:
a dll packaged into AB package, by www loaded AB package, obtained by reflection classes dll

WWW www = WWW.LoadFromCacheOrDownload(Application.streamingAssetsPath + "/hot.u3d",6);
        yield return www;
        if(www.error != null)
        {
            print(www.error);
            yield break;
        }
        AssetBundle assetBundle = www.assetBundle;
        TextAsset textAsset = assetBundle.LoadAsset<TextAsset>("HotFix");
        Assembly assembly = Assembly.Load(textAsset.bytes);
        foreach (var item in assembly.GetTypes())
        {
            print(item);
            gameObject.AddComponent(item);
        }

Note: Unity2017 does not support more than .Net3.5

android and IOS hot update What are the similarities and differences between
different points:
IOS does not allow some of the advanced features of reflection, and therefore can not do with the way hot update the DLL (mono when packaged, reflecting some of the features will automatically prohibit)
the same point:
end mobile hot updates are done using Unity3D + lua plugins or frameworks
hot update points to note:
resources, including the code of Lua code must reach assetbundle package to use
pay attention to several important path and folder:
resources (will be compressed, regardless of whether will be scored APK, read only)
StreamingAssets (not compressed, persistence directory, read only, can not take the heat update)
Application.datapath (Asset folder path below, can not do hot update)
carried (persistent data storage path, sandbox folder before you package this folder does not exist. readable and writable, no content restrictions, downloaded from the server AB resources, will be placed in this folder Application.persistentDataPath hot update)

Resource loading process
to start the game -> read local version number information -> to specify the server address to download the server version number information -> compare two version numbers -> If not, download all the resources from the server into AB (persistence directory go);

The first step in the process of loading each resource cube from the persistent attempt to load the directory, if not, that is loaded is empty, then load it from StreamingAssets folder;

unity3D those plug-in for hot update?
ULua poor performance based on the reflection efficiency low-speed slow gcalloc stop frequently to maintain only support Unity3D 5.0 before
ToLua more people use them to maintain a variety of fast static methods efficiency Gaoyao hot update file must use Lua code written
SLua not known project, code quality is better, you can read the source code using static methods drawback with tolua
C # Light uses less
XLua Tencent to develop open-source plug-hot update biggest advantage usually developed using C #, has encountered an error or problems need hot fix hot update when my son needed more heat script method of processing.

Guess you like

Origin blog.csdn.net/weixin_33712987/article/details/90965269