您的位置:首页 > 理论基础 > 计算机网络

Lua_ Lua结合BundleManager实现网络热更新_023

2017-09-09 10:52 375 查看

创建简单脚本

创建 lua_bundle_test.txt

内容很简单:

print(‘从服务器加载,并执行成功啦’);

使用BundleManager制作Bundle

制作Bundle



配置Bundle



之后Build



将该目录剪切到其他目录比如G:\

HttpFileServer

将剪切的目录拖放到右侧



加载Lua代码并执行

using UnityEngine;
using System.Collections;

using LuaInterface;

public class Test1 : MonoBehaviour {

// Use this for initialization
IEnumerator Start () {

DownloadManager.SetManualUrl("http://192.168.10.112:8080/StreamingAssets/Standalones/");
yield return StartCoroutine(DownloadManager.Instance.WaitDownload("lua_bundle.assetBundle"));
WWW www = DownloadManager.Instance.GetWWW("lua_bundle.assetBundle");
var bundle = www.assetBundle;

string[] assNames = bundle.GetAllAssetNames();

foreach(string s in assNames)
{
Debug.Log(s);
}

Object[] asss =  bundle.LoadAllAssets();

foreach(object obj in asss)
{

Debug.Log(obj.GetType());

}

TextAsset text = bundle.LoadAsset("lua_bundle_test") as TextAsset;

LuaState l = new LuaState();
l.DoString(text.text);

}

// Update is called once per frame
void Update () {

}
}


加载情况



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐