目录
代码全部:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using LuaInterface;
using System;
//click Lua/Build lua bundle
public class TestABLoader : MonoBehaviour
{
int bundleCount = int.MaxValue;
string tips = null;
IEnumerator CoLoadBundle(string name, string path)
{
using (WWW www = new WWW(path))
{
if (www == null)
{
Debugger.LogError(name + " bundle not exists");
yield break;
}
yield return www;
if (www.error != null)
{
Debugger.LogError(string.Format("Read {0} failed: {1}", path, www.error));
yield break;
}
--bundleCount;
LuaFileUtils.Instance.AddSearchBundle(name, www.assetBundle);//加入zipMap
www.Dispose();
}
}
IEnumerator LoadFinished()
{
while (bundleCount > 0)
{
yield return null;
}
OnBundleLoad();//所有的bundle加载完之后执行这个
}
public IEnumerator LoadBundles()
{
string streamingPath = Application.streamingAssetsPath.Replace('\\', '/');
#if UNITY_5 || UNITY_2017 || UNITY_2018
#if UNITY_ANDROID && !UNITY_EDITOR
string main = streamingPath + "/" + LuaConst.osDir + "/" + LuaConst.osDir;
#else
string main = "file:///" + streamingPath + "/" + LuaConst.osDir + "/" + LuaConst.osDir;
#endif
WWW www = new WWW(main);
yield return www;</