Для локализации игры решил использовать JSON файлы. В Unity Editor все работает отлично, но когда запускаю игру на Android весь текст пропадает. Почему так происходит?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
public class LangSystem : MonoBehaviour
{
private string json;
public static lang lng = new lang();
void Awake()
{
if (!PlayerPrefs.HasKey("Languages"))
{
if(Application.systemLanguage == SystemLanguage.Russian || Application.systemLanguage == SystemLanguage.Belarusian)
{
PlayerPrefs.SetString("Languages", "ru_RU");
} else if(Application.systemLanguage == SystemLanguage.Ukrainian)
{
PlayerPrefs.SetString("Languages", "ua_UKR");
} else
{
PlayerPrefs.SetString("Languages", "eng");
}
}
LangLoad();
}
void LangLoad()
{
#if UNITY_ANDROID && !UNITY_EDITOR
string path = Path.Combine(Application.streamingAssetsPath, "Language/" + PlayerPrefs.GetString("Languages") + ".json");
WWW reader = new WWW(path);
while(!reader.isDone) { }
json = reader.text;
#endif
#if UNITY_EDITOR
json = File.ReadAllText(Application.streamingAssetsPath + "/Language/" + PlayerPrefs.GetString("Languages") + ".json");
lng = JsonUtility.FromJson<lang>(json);
#endif
}
public void SwitchLang(string name)
{
switch (name)
{
case ("UA"):
PlayerPrefs.SetString("Languages", "ua_UKR");
break;
case ("RU"):
PlayerPrefs.SetString("Languages", "ru_RU");
break;
case ("ENG"):
PlayerPrefs.SetString("Languages", "eng");
break;
}
LangLoad();
}
}
public class lang
{
public string[] Menu = new string[3];
public string[] Options = new string[5];
public string[] NameDifficult = new string[3];
public string[] DiscriptionDifficult = new string[3];
}