Experience hot updates under the Tolua framework (Phpstudy)

Source: Internet
Author: User

A Detailed procedures for hot updates

    1. First we need to open the computer as a server, this is the first step

1.1.1 How to make sure that our computer is open as a server.

we open a browser and enter 127.0.0.1 in the Address bar . or localhost if the reality is not the link can not be linked to

as shown in the following:

Figure 1

1.1.2 If the link fails, download the IIS installation and open the relevant service. But here's another way to do this. We download phpstudy (software) installation has been installed until the last run boot appears Apache and MySQL both appear green can

at this point we re-link 127.0.0.1 will appear 1 of the interface, then our server even if it is a good

    1. The second step is to download our The Tolua framework is as follows: Https://github.com/jarjin/LuaFramework_UGUI

we are here to download good Tolua Framework It is a project (Zip package) We can see its file structure in the project:

Here we open Scenes folder under the main scene, and run:

Figure 2 The author has made a small change on this side, and the script on the empty object is hung up.

is the result of our operation, here's a look at the empty object in this scene Gamemanager the name of the empty object can not be changed, son Ah, run the scene space-time object only the main script and the code in this main script is extremely simple

public class Main:monobehaviour {

void Start () {

AppFacade.Instance.StartUp (); Start the game

}

}

There's only one simple sentence, and here we don't do a deeper study, The Appfacade class is a singleton, which encapsulates a number of methods. Startup is after we open our frame, we have this gamemanager empty object on the back automatically hang some scripts here not to discuss

    1. Some special classes in the Tolua framework

The Luamanager class is very important, and the Initstart method inside it is to start the LUA virtual machine (which can be considered a

Moving Lua)

Luastate control the state of LUA in this class we can run a LUA code (Dostring method) in C # with this class or execute the developed LUA code (Dofile (which is the path to a LUA file))

Lualooper controls the cycle of the entire LUA framework

Gamemanager: Here are some controls

here I go into the initialization of the project, at the beginning we just need to enter Initstart, and set initialize to True

No need to perform and load here

Appconst: The entire framework of the control class is here to configure the framework

UpdateMode set it to False when the server update is not available (you can turn him into false when testing) the game is going to be true if it is changed to true and will be updated with the following URL, False when it is updated locally

Luabundlemode: Controlling whether LUA code needs to be packaged LUA code will be packaged for each modification

Remember these classes

    1. Hot Update (Prepare article):

after installing a After Phpstudy we will have such a discovery, in our Phpstudy installation folder There is such a folder www folder, The resources to be updated in our project are put here (server) At this time we open our project (the package) Streamingassets folder copy of the file is placed here: (Please note this path)

Open the browser input address http://127.0.0.1/StreamingAssets/files.txt, and then we can see the results of the operation: please remember this access path

Figure 3

The content in Figure 3 is the content in our files.txt, when using the framework for hot update, the system will download the Files.txt and local comparison on the server, inconsistent content will be downloaded (UpdateMode set to True)

then we open the server Main.lua to see (This information is saved in the WWW folder)

--The main entry function. Starting from here, the LUA logic

function Main ()

Print ("Logic start")

Print ("This is a new LUA statement")

Print ("I'm new Here")

--print ("I'm really new here") These two sentences will not be executed

--print ("I'm new here too") These two sentences will not be executed.

End

--Scene Toggle Notification

function onlevelwasloaded (level)

CollectGarbage ("collect")

Time.timesincelevelload = 0

End

function Onapplicationquit ()

End

Then we compare our local ( the information in the streamingassets file of the WWW file is version 1.0, the following is the 2.0 version)

--The main entry function. Starting from here, the LUA logic

function Main ()

Print ("Logic start")

Print ("This is a new LUA statement")

Print ("I'm new Here")

Print ("I'm really new here")--will execute

Print ("I'm new here Too")--will execute

End

--Scene Toggle Notification

function onlevelwasloaded (level)

CollectGarbage ("collect")

Time.timesincelevelload = 0

End

function Onapplicationquit ()

End

This is the difference between the resources on the local and the server

5. Hot Update (run the article)

let's start by running the results locally updated ( UpdateMode set to False)

remember the 2.0 version of content packaging

Run the result, four statements all output, this is local update (server can only output two statements)

Figure 4

after we do the server-side updates, we open Appconst This file:

in this illustration, the UpdateMode set to True (updated from the server) below the Weburl (update path) to the previous red word let everyone remember the path (slightly different, see picture), save run. Results:

The resources on the server only output two sentences (different from the running results of the programmer locally)

------- Bai Ling Fox

phpstudy: Http://rj.baidu.com/soft/detail/17836.html?ald

this thing can be searched on Baidu

Experience hot updates under the Tolua framework (Phpstudy)

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.