[英]unity how to load image from streamingassets on ios
I put some png files into /Assets/StreamingAssets, what i want to do is load a image's texture from that floder. 我将一些png文件放入/ Assets / StreamingAssets,我想要做的是从该floder加载图像的纹理。
here is my c# code below: 这是我的c#代码如下:
string path = "file://" + Application.streamingAssetsPath + "/sunny.png";
private IEnumerator GetMatByWWW(string url)
{
WWW www = new WWW(url);
yield return www;
RawImage rawImage = gameObject.GetComponent<RawImage>();
rawImage.texture = www.texture;
}
On OSX, the code working perfect. 在OSX上,代码运行完美。 But i need to make it working on IOS.
但我需要让它在IOS上工作。 So i remove the prefix of "file://" and the path is :
所以我删除了“file://”的前缀,路径是:
string path = Application.streamingAssetsPath + "/sunny.png";
It just showed a red question-mark after build and run at my iPhone. 它只是在构建并在我的iPhone上运行后显示一个红色问号。 And i also tried
我也试过了
string path = "file:/" + Application.streamingAssetsPath + "/sunny.png";
Who can tell me how to do it correctly? 谁能告诉我如何正确地做到这一点?
string ab_path = Application.streamingAssetsPath + "/" + "bundlename";
AssetBundle ab = AssetBundle.LoadFromFile(ab_path);
if(ab == null)
{
Debug.Log("ab is null");
}
Gameobject prefab = ab.LoadAsset<GameObject>("prefab_name");
Gameobject go = GameObject.Instantiate(prefab);
please check this link. 请检查此链接。 https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html
https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.