【发布时间】:2017-08-24 12:14:01
【问题描述】:
当我在我的电脑上运行它时,我可以从外部 url 加载图像并将它们保存到我的统一项目文件夹中(统一播放器场景)它完美地工作我可以将位于我的项目中的图像加载到纹理表中并显示它但它在 android 设备上运行时不起作用。它不会将图像加载到纹理中
DirectoryInfo info = new DirectoryInfo(@"Assets\Photos\");
int nbImage;
nbImage = info.GetFiles("*.jpg").Length;
Debug.Log(nbImage);
Textures = new Texture2D[nbImage];
for (int i = 0; i < nbImage; i++)
{
string e = Application.streamingAssetsPath + "/" + i + ".jpg";
byte[] bytes;
bytes = System.IO.File.ReadAllBytes(e);
load_s01_texture = new Texture2D(1, 1);
load_s01_texture.LoadImage(bytes);
Textures[i] = load_s01_texture as Texture2D;
}
【问题讨论】:
-
你试过调试吗?如果没有,您可以通过在手机上启用 USB 调试(在开发人员设置中)并使用 ADB(一个常用命令是
adb logcat -s Unity)来实现。 -
是的,我尝试在 android studio 上调试它,我认为这是路径问题。他找不到我保存在项目中的图像的路径
标签: c# android unity3d texture2d