2017-02-23 6 views
1

私は/ Assets/StreamingAssetsにいくつかのpngファイルを入れました。私がしたいのは、そのフロダーからイメージのテクスチャをロードすることです。 OSX、コード作業完璧にユニティios上でstreamingassetsからイメージをロードする方法

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; 
} 

:ここ

は、以下の私のC#のコードです。しかし、IOS上で動作させる必要があります。 「ファイル://」だから私は、の接頭辞を削除し、パスは次のとおりです。

string path = Application.streamingAssetsPath + "/sunny.png"; 

はそれだけでビルド後の赤い疑問符を示し、私のiPhoneで実行します。私も試しました

string path = "file:/" + Application.streamingAssetsPath + "/sunny.png"; 

私はそれを正しく行う方法を教えてもらえますか?

答えて

0
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); 

このリンクを確認してください。 https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html

関連する問題