Json doesnt work in android (unity)
First sorry about my english. i cannot read the info from my json and i try some tutorial and google links and im tired to dont found the answer. when i test in the unity editor works properly but when i build for android i cannot get the info. This is my code.
string filePath;
string jsonString;
string destino = "/Scrips/datos.json";
public int sensibilidadX;
public int sensibilidadY;
void Start () {
filePath = Application.dataPath + destino;
jsonString = File.ReadAllText(filePath);
Jsonsch datus = JsonUtility.FromJson<Jsonsch>(jsonString);
sensibilidadX = datus.jsonschema[0].sensibilidad[0];
sensibilidadY = datus.jsonschema[0].sensibilidad[1];
Reset();
}
Please elaborate on "cannot get the info". Are there any errors? Do you end up with a "null"? have you tried Debug.Log to some extent, and what did you find from that?
I wonder if folder name should be "Scripts" ins$$anonymous$$d of "Scrips" (missing letter "t")
Isn't this more like a comment? Just wondering...
Hi @Section2712 - This might be an issue (not 100% sure); your filePath is "Application.datapath" - This is actually path to Unity project's Asset folder, which is used during development. You should probably be using Application.persistentDataPath ins$$anonymous$$d, which is meant for the purpose: https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html
Edit - there is also very thorough answer about these paths, which might be helpful: https://answers.unity.com/questions/1181652/difference-between-applicationpersistantdatapath-v.html