First: Unity3d game development of the mobile end of the complete package update scheme

Source: Internet
Author: User

Since unity is not able to perform hot updates, that is, local updates, if you did not consider using LUA, reflection, or other means to implement hot updates prior to the design, but also facing the game on-line then you can consider using the full package update, in fact, this is not a big game package, is a good choice , of course, designers at the beginning of the design to think good hot update that would rather be conceivable.

Unity3d on the mobile side of the Android and iOS platform to consider the full package update implementation logic: first check whether the local version and server version is the same , if the same directly into the game, if different download the server's latest files, Then download the latest installation package based on the latest file to the resource server

I have a version of the file here, such as different games corresponding to the version of the file different, this look at the situation

?????? Version number update log download link (version comparison will only compare version numbers, corresponding download links must correspond to the specified package)
0.0.0 http ://***/test.apk
7.24 first version package http:/***/test1.0.0.apk

iOS: Because the iOS platform is beyond our control, jump directly to the corresponding iOS update directory

Android: Android platform requires automatic version forcing user update

Specific use of the following scenarios

using Unityengine; using System.Collections;  Public Interface iplatformupdate{    void doplatformupdate (string  downloadurl);
usingUnityengine;usingSystem.Collections; Public classCplatfromfactory { Public StaticIplatformupdate Createplatfrom (stringplatfrom) {Iplatformupdate Platform=NULL; if(Platfrom. Equals ("Android") ) {Platform=Newcandroidupdate (); }        Else if(Platfrom. Equals ("IOS") ) {Platform=Newciosupdate (); }        returnplatform; }}
usingUnityengine;usingSystem.Collections; Public classcandroidupdate:iplatformupdate{ Public voidDoplatformupdate (stringDownloadURL) {
Some features of Android are required for automatic installation. This makes an Android plugin for unity to invoke. Specifically, in the current activity there is a downloadapk method to accept a string parameter, and then it is the function of Android.
Specific Android How to implement can Baidu, very simple code, here no longer record Androidjavaclass InstallClass
=NewAndroidjavaclass ("Com.unity3d.player.UnityPlayer"); Androidjavaobject Installobj= Installclass.getstatic<androidjavaobject> ("currentactivity"); Installobj.call ("downloadapk", DownloadURL); }}
using Unityengine; using System.Collections;  Public class ciosupdate:iplatformupdate{    publicvoid doplatformupdate (string  DownloadURL)    {
Open the corresponding connection, which is usually saved in the version file Version.txt application.openurl (DownloadURL);} }

Problems encountered in the development: the Android phone in the USB interface when the memory card can not be written, that is, unable to install a new package, you need to pull the line, this problem tangled for a long time, has been prompted memory card does not have write permission.

Welcome to shoot Bricks!!!

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.