我尝试通过www从我的服务器下载图像。在UnityPlayer中它没问题,但是当我在xcode上运行app时它会崩溃。
我检查登录服务器,并且只有来自网络播放器的ios没有请求:
109.252.44.138 - - [17 / Feb / 2018:09:53:18 +0300]" POST /unityConnect.php HTTP / 1.0" 200 604" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 452 746 0 125187 109.252.44.138 - - [17 / Feb / 2018:09:53:39 +0300]" POST /unityConnect.php HTTP / 1.0" 200 14" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 563 156 0 2266 109.252.44.138 - - [17 / Feb / 2018:09:53:39 +0300]" POST /unityConnect.php HTTP / 1.0" 200 170" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 421 312 0 1807 109.252.44.138 - - [17 / Feb / 2018:09:53:43 +0300]" POST /unityConnect.php HTTP / 1.0" 200 992" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 430 1134 0 243826 109.252.44.138 - - [17 / Feb / 2018:09:53:45 +0300]" POST /unityConnect.php HTTP / 1.0" 200 604" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 452 746 0 2482 109.252.44.138 - - [17 / Feb / 2018:09:54:05 +0300]" POST /unityConnect.php HTTP / 1.0" 200 604" - " " cocktailparty / 27 CFNetwork / 893.14.2达尔文/ 17.3.0" 452 746 0 2452 109.252.44.138 - - [17 / Feb / 2018:09:54:25 +0300]" POST /unityConnect.php HTTP / 1.0" 200 13" - " " UnityPlayer / 2017.3.0f3 (UnityWebRequest / 1.0,libcurl / 7.51.0-DEV)" 595 155 0 1760 109.252.44.138 - - [17 / Feb / 2018:09:54:25 +0300]" POST /unityConnect.php HTTP / 1.0" 200 170" - " " UnityPlayer / 2017.3.0f3 (UnityWebRequest / 1.0,libcurl / 7.51.0-DEV)" 414 312 0 1034 109.252.44.138 - - [17 / Feb / 2018:09:54:29 +0300]" POST /unityConnect.php HTTP / 1.0" 200 992" - " " UnityPlayer / 2017.3.0f3 (UnityWebRequest / 1.0,libcurl / 7.51.0-DEV)" 423 1134 0 263959 109.252.44.138 - - [17 / Feb / 2018:09:54:32 +0300]" POST /unityConnect.php HTTP / 1.0" 200 604" - " " UnityPlayer / 2017.3.0f3 (UnityWebRequest / 1.0,libcurl / 7.51.0-DEV)" 445 746 0 3588 109.252.44.138 - - [17 / Feb / 2018:09:54:32 +0300]" GET /img/0002.jpg HTTP / 1.1" 200 73962" - " " UnityPlayer / 2017.3.0f3(UnityWebRequest / 1.0, 的libcurl / 7.51.0-DEV)"
代码:
public void GetFullReceiptMySQL(Dictionary <string, string> [] newReader)
{
StartCoroutine(StartLoad(newReader[0]["id"], newReader));
}
IEnumerator StartLoad(string idCocktail, Dictionary <string, string> [] newReader)
{
// testing parameter 0002, image 0002 present on server
string imageUrl = GetFullSourceCocktailImage("0002");
WWW www = new WWW(imageUrl);
Debug.Log(imageUrl);
// Wait for download to complete
Debug.Log ("Done1? " + www.isDone + " progress " + www.progress + " or with error " + www.error) ;
yield return www;
Debug.Log ("Done2? " + www.isDone + " progress " + www.progress + " or with error " + www.error) ;
if (!string.IsNullOrEmpty(www.error))
{
Debug.Log("error " + www.error);
}
else
{
Debug.Log("image ready" + www.error);
RawImage image = GetComponent<KeeperScript>().imageCocktailInReceipt;
Texture2D newTexture = new Texture2D(www.texture.width, www.texture.height);
www.LoadImageIntoTexture(newTexture as Texture2D);
image.GetComponent<RawImage>().texture= newTexture;
MakeAllReceipt(newReader);
}
DestroyImmediate(www.texture);
www.Dispose();
www = null;
Resources.UnloadUnusedAssets();
}
在日志中的XCode中出现错误404