Answer the question
In order to leave comments, you need to log in
JSON file encoding in Unity 3D. What to put for Cyrillic?
Good day. I am making multilanguage for my game on JSON. The English dictionary is loaded without problems, but when I put Russian - the variables are just empty, nothing is displayed. I put the ANSI file encoding - squares (unknown characters) are issued. What encoding should be used for normal display? Everything is fine on the computer - the problem is on the ANDROiD device . The code is as follows (the compiler does not throw any errors):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class LangSystem : MonoBehaviour {
private string json;
public static lang lng = new lang();
void Awake()
{
LangLoad();
}
void LangLoad()
{
#if UNITY_ANDROID && !UNITY_EDITOR
string path = Path.Combine(Application.streamingAssetsPath, "Language/ru_RU.json");
WWW reader = new WWW(path);
while (!reader.isDone) { }
json = reader.text;
lng = JsonUtility.FromJson<lang>(json);
#endif
#if UNITY_EDITOR
json = File.ReadAllText(Application.streamingAssetsPath + "/Language/ru_RU.json");
lng = JsonUtility.FromJson<lang>(json);
#endif
}
}
public class lang
{
public string[] sports = new string[100];
public string[] geo = new string[100];
public string applicationName;
public string startGame;
public string rules;
public string settings;
public string quit;
}
{
"applicationName":"МОЯ ИГРА!",
"startGame":"НАЧАТЬ ИГРУ",
"rules":"ПРАВИЛА",
"settings":"НАСТРОЙКИ",
"quit":"ВЫХОД",
"ncat":"СЛОВО",
"scat":"СЛОВО",
"at":"СЛОВО",
"cat":"СЛОВО",
"back":"СЛОВО",
"sports":[
"СЛОВО","СЛОВО","СЛОВО","СЛОВО","СЛОВО"
],
"geo":[
"СЛОВО","СЛОВО","СЛОВО","СЛОВО","СЛОВО"
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question