Excuse my previous thread, i didn't know how to delete it. I have a strange issue where I just use the streamingassetpath to load a file, but it appears as though a slash is being prepended. Code (CSharp): public static readonly string LANG_DIR = Application.streamingAssetsPath + Path.DirectorySeparatorChar + "Languages"; Code (CSharp): isoCode = enumToISO639(langType); string languageFile = Path.Combine(Config.LANG_DIR + String.Format(Path.DirectorySeparatorChar + "{0}.json", isoCode.ToUpper())); File.ReadAllText(languageFile); addTranslationKeys(File.ReadAllText(languageFile)); Code (CSharp): Could not find a part of the path "/jar:file:/data/app/com.oculus.ClickVRPlayerDev-M_ZpiDMPbfCCiAW0_-xpCw==/base.apk!/assets/Languages/ENG.json".
While you could just remove the starting slash, there is a different issue in play. File.ReadAllText on Android doesn't work with streamingAssets anyways. https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html You can read about it here. You could also try using the Path.Combine call instead.
I can't remove the starting slash because i tried it with substring and it will just start changing the "/jar:file" to "/ar:file", so the first / is added by something external? I already use path combine and I don't see why loadalltext wouldn't work as I also used a different method of loading the file using streamreader and that didn't work either and gave the same path error.
The link I gave you tells you how you load from streaming assets on Android and explains why you have to do it that way. I don't know where your starting slash is coming from.
I tried doing it like this but to no avail Code (CSharp): private void initTranslations() { isoCode = enumToISO639(langType); string languageFile = Path.Combine(Config.LANG_DIR + String.Format(Path.DirectorySeparatorChar + "{0}.json", isoCode.ToUpper())); try { #if UNITY_EDITOR addTranslationKeys(File.ReadAllText(languageFile)); #elif !UNITY_EDITOR && UNITY_ANDROID readFileAndroid(languageFile); #endif } catch (Exception e) { if (Debug.isDebugBuild) Debug.Log("Failed to load language file"); } } private IEnumerator readFileAndroid(string path) { UnityWebRequest request = new UnityWebRequest(path); yield return request.SendWebRequest(); addTranslationKeys(request.downloadHandler.text); } for now i will just put the json lines into a static class because this just doesn't appear to be working
You can put a JSON file in your Resources directory for this. This will work on all platforms, and in the editor. e.g. for Resources\language.json: Code (CSharp): var textAsset = Resources.Load<TextAsset>("language"); string text = textAsset.text;