无法使用unity3d从Android中的持久路径获取图像 [英] Not getting image from Persistant path in Android using unity3d

查看:45
本文介绍了无法使用unity3d从Android中的持久路径获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本来截取屏幕截图并保存该图像,并在飞机上显示该图像.

I have a script to take screenshot and save that image and to show that image in a plane.

但是没有那种质地.

private string path;

void Start () {
       path = Application.persistentDataPath;
    }

void captureScreeshot(){ 
    Application.CaptureScreenshot(path + "/Screenshot.png");
    alert.text = "saved";
    StartCoroutine(saveScreenshot()); 
    onetimeBool = false;
}
IEnumerator saveScreenshot(){
    WWW imgfile = new WWW("file://" + path+ "/Screenshot.png");
    yield return imgfile;
    if(imgfile.error==null){
       img = new Texture2D(200, 200, TextureFormat.RGB24, false); 
       imgfile.LoadImageIntoTexture(img);
       alert.text = "got image";
        GameObject.Find("plane").renderer.material.mainTexture = img;

    }else{
       print(imgfile.error);
    }
}

图像已保存.

但是我无法在系统和android中打开(加载)图像.

But I cannot open (load) image in system and android.

在系统中出现错误:

无法打开文件/Users/ether/AppData/LocalLow/Company/Project/Screenshot.png

Couldn't open file /Users/ether/AppData/LocalLow/Company/Project/Screenshot.png

如何获取???

推荐答案

这是因为您的路径错误,因此应使用:application.dataPath,而不是Application.persistentDataPath.

This is because your path is wrong, you should use: application.dataPath, instead of Application.persistentDataPath.

这篇关于无法使用unity3d从Android中的持久路径获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆