今天在讀取Application.persistentDataPath路徑下的圖片時,在前面加上「file:///」 例如spa
#if UNITY_EDITOR || UNITY_STANDALONE return "file:///" + Application.persistentDataPath + "1.jpg"; #elif UNITY_ANDROID return "file:///" +Application.persistentDataPath + "1.jpg"; #else return "file:///" +Application.persistentDataPath + "1.jpg"; #endif
搞了半天 www 加載 在前面加「jar:file///」 沒有用 不加也沒有用,只有在前面加"file:///"才行;code
另外 FileStream 讀取文件時遇到一些問題blog
string ConfigurationFile= ""; #if UNITY_EDITOR ConfigurationFile = Application.streamingAssetsPath + "/ConfigurationFile.txt"; #elif UNITY_ANDROID ConfigurationFile =Application.streamingAssetsPath + "/ConfigurationFile.txt"; #elif UNITY_STANDALONE ConfigurationFile = Application.streamingAssetsPath + "/ConfigurationFile.txt"; #endif FileStream file = new FileStream(ConfigurationFile, FileMode.Open);
有沒有發現 fileStream 地址不能加 file:///圖片