在Unity3d中加载iphone的图像

我使用iOS Unity插件将图像path发送到统一。 在Unity中,我尝试使用接收的path来获取这个图像(我没有其他想法如何将图像从iphone发送到统一)。 问题:我仍然无法获得图像。 WWW错误:在此服务器上找不到请求的URL。

//Tried both "file:///..." and "file://..." string path = "file://var/mobile/Applications/173DE26D-4C0E-4DF7-9DC6-9CBB7D4FC954/Documents/Images/image.png" Texture texture; IEnumerator WaitForRequest(WWW www) { yield return www; if (www.error == null) { texture = www.texture; } } void Start() { WWW www = new WWW(path); StartCoroutine(WaitForRequest(www)); } 

确保文件在那里使用

 System.IO.File.Exists("/var/mobile/Applications/173DE26D-4C0E-4DF7-9DC6-9CBB7D4FC954/Documents/Images/image.png") 

因为你的代码看起来正确。

此外,而不是硬编码的path,你应该使用Application.persistentDataPath。

 string path = "file://" + System.IO.Path.Combine(Application.persistentDataPath, "Images/image.png"); 

顺便说一句,我认为一个绝对的文件url应该始终以file:///开头。