Unity3d on Android Android update (APK overlay)

Source: Internet
Author: User

In fact, this does not have technical difficulties, nor is the perfect heat update program, can only be said to be the next step back to a method.

The cause is mainly because the company several U3D projects at the beginning of the project has not been able to do a hot update of the regulation, resulting in the current to do u3d hot update is very difficult, and the project is in the middle and late, most of the program whether with reflection, or with Lua, or jsbinding, It's very unrealistic to have to put most of the project's code structure down. Then go back to the second, choose or directly with the minimum apk to update the game.

Maybe a lot of people do that, but not to share, the purpose of this blog is to write about the Internet is very difficult to find the relevant collation, and most of the game makers are only for the development of games and unity will be more familiar with Andriod and iOS is not familiar with, so some methods may be thought of, But if no one to verify, always still do not trust, so it is intended to record and share to everyone.

The Focus of the program is: the user in the first installation of the game can be installed with the full APK package, after which if there is logic code needs to be updated, only need to help users download a minimum of 7MB apk to the game overlay installation. (although this 7MB or so is relatively large)

I would like to emphasize that this approach is 100% feasible, only suitable for Android, has been verified, and is in use, no better plan will always be used, there is a good update program will be updated in the blog, and also hope that we can share.

There are two ways to update resources in U3d, both of which guarantee the game's resource update, which is not specified in detail:

1. WWW.LoadFromCacheOrDownload, this approach is mostly only supported by Assetbundle, so you need to package all the files into Assetbundle.

2. www after using file to write to disk, this way you have to control the version.

To update the game logic with the minimum apk:

The first step: Copy the APK installation path Application.datapath Asset directory file to the read-write directory Application.persistentdatapath

The first time you initialize a game, you need to load all the resources used in the game via WWW.LoadFromCacheOrDownload (or www+file, all asset into a ZIP package when you pack the APK. Unzip to application.persistentdatapath the first time you start the game, and let them put into the cache (this process depends on the size of the game installation package, and of course, you can do this when other things you feel are appropriate).

Step Two: make the minimum installation package

Empty the files in the project Streamingassets this directory and then pack an APK with unity, which is about 7MB.

Step Three: update the logic

Put the smallest apk you've made on the Web server, download it through WWW.bytes, and write it to Application.persistentdatapath with FileStream.

Fourth Step: call Andriod system API, to perform the APK installation (how to call Baidu Search "Unity andriod interaction", "Andriod Install APK Code").

This installation will overwrite the previously installed APK, because the asset directory in this apk is empty, so there is no asset after overwriting, which is why the first step is the reason. In addition, when this application.persistentdatapath+filename is called in the Java side, it needs to add "file://" at the front of the path.

The emphasis here is that after reinstalling the APK, the Application.persistentdatapath and WWW.LoadFromCacheOrDownload cached files will not be overwritten, so please feel free to overwrite the original apk.

Although this method is not very human, every time you want to download the minimum update package is 7mb+, and each time also pop up the andriod on the installation of the APK dialog box, but, who told us in the initial use of u3d when not good planning under the hot update problem.

At the same time, we also call on Unity3d official can give a hot update plan, at least give andriod logic heat more scheme, obviously only need to change the *.so load path to configurable, we can easily implement the logic of the hot update, but did not provide such a method. I just want to say, Unreal4 all open source, Unity3d also take what competition.

Original address: http://www.cnblogs.com/aizquan/p/5055503.html

Unity3d on Android Android update (APK overlay)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.