在编辑器模式下加载streamingassets下的图片没问题,打包PC后加载出来的是红色感叹号。
IEnumerator IETexture(string path, RawImage tex)
{
string pa = Path.Combine(Application.streamingAssetsPath + "/" + path+".png");
UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture(pa);
yield return webRequest.SendWebRequest();
Debug.LogError(webRequest.error);
if (DownloadHandlerTexture.GetContent(webRequest) != null)
{
Texture2D texture = DownloadHandlerTexture.GetContent(webRequest);
tex.texture = texture;
}
}
Debug.LogError(webRequest.error)的结果也为空,但就是加载的图片变成红色感叹号
在地址前加一个本地协议试试
UnityWebRequest webRequest = UnityWebRequestTexture.GetTexture("file://"+pa);
双斜杠就行,不行就是三斜杠
接口倒是没问题,有可能是图的问题,有试过换一张图吗
调用的地方代码贴出来看看,感觉是调用出的问题