0

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?

likuku
  • 358
  • 6
  • 21

1 Answers1

0

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
aalmigthy
  • 1,261
  • 8
  • 19
  • thanks for your help. I'm editing someone elses code so I'll need to give a deeper look. I hoped it might be something in the settings. apart from this, I think that www is deprecated for some time now – likuku Sep 23 '19 at 19:29
  • Thanks for the info, i am mainly working on 2017 LTS and missed that. But it seems you can use [WebRequest](https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html?_ga=2.259344714.1180410755.1569276422-1322956326.1506024611) the same way. – aalmigthy Sep 23 '19 at 22:11