hello
i am trying to save data on json file on Android device.
i use this code to read the file:
string filePath = Application.streamingAssetsPath + "/data.json";
string dataAsJson;
if (Application.platform == RuntimePlatform.Android)
{
WWW reader = new WWW(filePath);
while (!reader.isDone) { }
dataAsJson = reader.text;
}
else
{
dataAsJson = File.ReadAllText(filePath);
}
myData = JsonUtility.FromJson<data>(dataAsJson);
and this code to save the file
dataAsJson = JsonUtility.ToJson (myData);
File.WriteAllText (filePath, dataAsJson);
Sorry, my bad. It should be: float score = PlayerPrefs.GetFloat("Highscore"); score -= item.Value; @Ashmit2020 ---------- To save what the player bought, you might want to use something a little different to PlayerPrefs. You could save an individual string for each item into playerPrefs, but it would be easier to write to a text file, containing the contents of what you bought, then reading it back again, when loading your inventory. ---------- You're asking a lot of questions, and it would be easier to answer individual questions. Maybe you could post another question?
– Llama_w_2Ls