Reputation: 358
I'm working on a project that involves reading content from StreamingAssets.
It works perfectly in the unity engine and in the Oculus Rift but when exporting apk to Oculus Quest/Go the streaming does not occur (quiz doesn't load).
have anyone encountered Issues with accessing StreamingAssets via Quest/Go apps? did you solve it?
things I tested: reading promissions: external force internal i checked logcat via android studio (empty).
the main functions are those:
private string getPath()
{
#if UNITY_EDITOR
return Application.streamingAssetsPath;
#elif UNITY_ANDROID
return Application.persistentDataPath;
#elif UNITY_STANDALONE_WIN
return Application.streamingAssetsPath;
#else
return "";
#endif
}
private string[] loadExternal_Question(int qIndex)
{
Debug.Log("External File: " + getPath() + "/Quiz/Q" + qIndex + ".txt");
string[] q_Data = File.ReadAllLines(getPath() + "/Quiz/Q" + qIndex + ".txt");
QuestionTitle_LB.text = q_Data[0].Replace("//n", "\n");
Answer_1.text = q_Data[1].Replace("//n", "\n");
Answer_2.text = q_Data[2].Replace("//n", "\n");
Answer_3.text = q_Data[3].Replace("//n", "\n");
Answer_4.text = q_Data[4].Replace("//n", "\n");
CurrentQ = int.Parse(q_Data[5]);
FeedBack_LB.text = q_Data[6].Replace("//n", "\n");
return q_Data;
}
I notice that the issue can be caused by the fact that the info is in streamingAssets. but how can i define a persistentDataPath in unity so it can read from there? or else, can Android apps for Quest/Go read from StreamingAssets?
Upvotes: 0
Views: 2128
Reputation: 1311
The content of StreaminAssets is compressed inside the APK. How do you access it? If you want to open a text file you can do something like this:
string json;
#if UNITY_EDITOR || !UNITY_ANDROID
json = File.ReadAllText(StreamingJsonPath);
#else
// streamingAssets are compressed in android (not readable with File).
WWW reader = new WWW (StreamingJsonPath);
while (!reader.isDone) {}
json = reader.text;
#endif
Upvotes: 0