ios - Unity3D如何从iPhone下载图片?
高洛峰
高洛峰 2017-04-17 12:04:10
0
1
275

JastinBall
我用iOS Unity插件给Unity发送了图像路径。在Unity中,我尝试着用收到的路径获取图片(我不知道如何把iPhone的图片发送到Unity)。问题是:我还没能获得图片。WWW Error: The requested URL was not found on this server. (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)); }

原问题:Loading image from iphone in Unity3d

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回覆 (1)
Peter_Zhu

Calvin:
确保文件是正在被使用着的:

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

因为你的代码看上去是正确的。
还有,不应写死路径,你应该使用Application.persistentDataPath。

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

顺便说一句,绝对文件URL应该始终以file:///开始。

    最新下載
    更多>
    網站特效
    網站源碼
    網站素材
    前端模板
    關於我們 免責聲明 Sitemap
    PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!