//AB包(UnityWebRequest request 异步执行)
[LuaCallCSharp]
public void LoadResource(string resName,string filePath)
{
StartCoroutine(LoadResourceCorotine(resName,filePath));
}

IEnumerator LoadResourceCorotine(string resName,string filePath)
{
    UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(@"http://localhost/AssetBundles/" + filePath); 
    yield return request.SendWebRequest();
    AssetBundle ab = (request.downloadHandler as DownloadHandlerAssetBundle).assetBundle;

    GameObject gameObject = ab.LoadAsset<GameObject>(resName);
    prefabDict.Add(resName, gameObject); 
}

/////////////////////////////////////////////////////////////////////////

// Lua脚本(加载场景时同时加载NetBox上的Lua脚本保存到本地(本地存在时直接覆盖源文件))
public void LoadGameMethod()
{
StartCoroutine(LoadResourceCorotine());
StartCoroutine(StartLoading_4(2));
}

IEnumerator LoadResourceCorotine()
{
    UnityWebRequest request = UnityWebRequest.Get(@"http://localhost/fish.lua.txt");
    yield return request.SendWebRequest();
    string str = request.downloadHandler.text;//获取下载的脚本文本
    File.WriteAllText(@"D:\715\XluaProjects\PlayerGamePackage\fish.lua.txt", str);存储到本地

    UnityWebRequest request1 = UnityWebRequest.Get(@"http://localhost/fishDispose.lua.txt");
    yield return request1.SendWebRequest();
    string str1 = request1.downloadHandler.text;
    File.WriteAllText(@"D:\715\XluaProjects\PlayerGamePackage\fishDispose.lua.txt", str1);
}