"how to save data on cellphone unity android" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "how to save data on cellphone unity android" answered properly. Developers are finding an appropriate answer about how to save data on cellphone unity android related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like how to save data on cellphone unity android. Enter your desired code related query in the search bar and get every piece of information about C# code related question on how to save data on cellphone unity android.
how to save data on cellphone unity android
using System.IO public class scoreFile { private int[] level; private bool[] completed; private float[] completionTime; private string[] scores; private string fileName; //This class stores information for each of the levels. public scoreFile(int num) { fileName = "scores.txt"; try { if (!File.Exists(fileName)) { level = new int[num]; completionTime = new float[num]; completed = new bool[num]; scores = new string[num]; Debug.Log("Opened file!"); for (int i = 0; i < num; i++) { level[i] = i + 1; completionTime[i] = 0; completed[i] = false; scores[i] = level[i] + " " + 0 + " " + completionTime[i]; } Debug.Log("About to write into file!"); File.WriteAllLines(fileName, scores); } else { Debug.Log("File is exist! Loading!"); loadFile(); } } catch (System.Exception e) { Debug.Log(e); } } public bool isComplete(int i) { return completed[i]; } public int levels(int i) { return level[i - 1] + 1; } public float timeScore(int i) { return completionTime[i]; } public void loadFile() { Debug.Log("Reading"); string[] levelsInfo = File.ReadAllLines(fileName); int num = levelsInfo.Length; level = new int[num]; completionTime = new float[num]; completed = new bool[num]; for (int i = 0; i < num; i++) { //Debug.Log(levelsInfo[i]); string str = levelsInfo[i]; level[i] = (int)int.Parse(str.Substring(0, 1)); int f = int.Parse(str.Substring(2, 1)); if (f == 0) completed[i] = false; else completed[i] = true; completionTime[i] = (float)float.Parse(str.Substring(4)); } } }
Source: answers.unity.com
All those coders who are working on the C# based application and are stuck on how to save data on cellphone unity android can get a collection of related answers to their query. Programmers need to enter their query on how to save data on cellphone unity android related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to save data on cellphone unity android for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of how to save data on cellphone unity android while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "how to save data on cellphone unity android". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to save data on cellphone unity android resolved professionally and stay updated to the latest C# updates.