Unity and Lua Interaction

Source: Internet
Author: User
Tags lua

Using LUA means that the project uses a hot update, and usually each hot update gets the latest LUA script from the server onto the local directory of the Android/ios device, but where does Lua go, and here's the path to the LUA problem?

1, can not be placed in the resources folder, because cannot find its location under the device, resources under the things are managed by unity, when used by Resources.load/loadall to load

2, can not put to Streamingassets folder, because in the device Streamingassets folder inside the resources can only read, cannot write, when we hot update the latest resources, is not good operation! And the things under the Streamingassets folder will eventually be bundled into a pkg.apk apk installer when the APK is built, unzip the pkg.apk to see the resources under the Streamingassets folder, set the player when unity is out of the package. The installation location under Settings is Perfer External (priority installation to external devices, that is, sdcard), install this package and view it with file Viewer to see the files installed by this program, usually as follows:

COM.ZWH.P1 is my package name, if the program is installed on the outside, then all can see his installation files, other applications are the same

If the install location is set to force Internal (forced to install to the phone memory), then you cannot see the program's installation files!

How to access resources under the Streamingassets file:

stringGetstreamingassetspath () {return             #ifUnity_android//"Jar:file://"+ Application.datapath +"!/assets/"; unityengine.application.streamingassetspath+"/"; #elifUnity_iphoneApplication.datapath+"/raw/"; #elifUnity_standalone_win | | Unity_editor"file://"+ Application.datapath +"/streamingassets/"; #else              string.              Empty; #endif         }

3, first look at unity in several paths related to the class, on the Android platform output path why

Debug.Log ("Temporarycachepath ="+UnityEngine.Application.temporaryCachePath); //temporarycachepath =/storage/sdcard0/android/data/com.zwh.p1/cache Debug.Log ("DataPath ="+UnityEngine.Application.dataPath); //datapath =/mnt/asec/com.zwh.p1-2/pkg.apk Debug.Log ("Persistentdatapath ="+UnityEngine.Application.persistentDataPath); //persistentdatapath =/storage/sdcard0/android/data/com.zwh.p1/files Debug.Log ("Streamingassetspath ="+ UnityEngine.Application.streamingAssetsPath);//streamingassetspath = Jar:file:///mnt/asec/com.zwh.p1-2/pkg.apk!/assets

It can be seen that datapath and Streamingassetspath refer to the location of the program installation, while Temporarycachepath and Persistentdatapath refer to the location of SDcard, So you can choose between these two paths as a place to store LUA files, if unity is out of the package, to set playersettings under Write access to external (sdcard), otherwise the location of the two paths is not the same!

Unity and Lua Interaction

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.