Trigger 老师您好:
在学习捕鱼达人热更新实战时,我的LoadGame.cs脚本无法从远程服务器获取到fish.lua.txt以及fishDispose.lua.txt.
加载脚本如下:
IEnumerator LoadResourceCorotine()
{
UnityWebRequest request = UnityWebRequest.Get(@"http://localhost/fish.lua.txt");
yield return request.SendWebRequest();
string str = request.downloadHandler.text;
print(str);
File.WriteAllText(HotFixScript. localLuaPath+ "fish.lua.txt", str);
UnityWebRequest request1 = UnityWebRequest.Get(@"http://localhost/fishDispose.lua.txt");
yield return request1.SendWebRequest();
string str1 = request1.downloadHandler.text;
File.WriteAllText(HotFixScript.localLuaPath + "fishDispose.lua.txt", str1);
}
已确定:
1)NetBox2.exe 已经运行
2)fish.lua.txt以及fishDispose.lua.txt.在NetBox2.exe.的同级目录,和index.html在同一个目录
print(str)结果:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
UnityEngine.MonoBehaviour:print(Object)
<LoadResourceCorotine>c__Iterator1:MoveNext() (at Assets/Scripts/Player/UI/LoadGame.cs:62)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
同学你好,同学粘过来的代码是没有问题的,同学的lua脚本有没有保存成utf-8编码格式的?还有同学的index.html是不是加了一些其他的内容,是不是写的html语法有写问题,如果同学没有解决问题可以把原工程发给老师,老师抽空帮同学看看。