//============================================================= /** * @brief KeyPairText i/o example */ //============================================================= void PlainExample() { // Please check the "Tsv/KeyPairTextExample.tsv". Tsvio tsvio = new Tsvio(Tsvio.Mode.PlainText); string path = "Tsv/PlainTextExample"; TextAsset txt = Resources.Load("Tsv/PlainTextExample", typeof(TextAsset)) as TextAsset; string tsv_text = Encoding.UTF8.GetString(txt.bytes); parseResult = new StringBuilder(); // If you want to see the console messages, then set to true below. tsvio.debugMode = false; // Set log function callback. tsvio.DelegateLog = AppendLog; AppendLog( "***************************\n" + "The loaded elements tree made for debugging.\n" + "Please open the example tsv file from " + path + ".\n" + "and, Compare tree in the hierarchy tab.\n" + "***************************\n"); // For example project. if (debugTree != null) { debugTree.Clear(); } else { debugTree = new TsvElementDebug(); } // Parse the tree structured tsv string. if (tsvio.Parse(tsv_text)) { int len = tsvio.plain.Length; // Set Element tree visualize debug by the GameObjects tree. debugTree.Parse(tsvio.plain, "[Tsvio] Root"); //####################################################### // // GetAttributes example // //####################################################### for (int i = 0; i < len; ++i) { AppendLog("PlainExample[" + i + "]:" + string.Join(", ", tsvio.plain[i])); } //####################################################### // // Ways of add elements, and SaveTo example // //####################################################### int n = 10; string[][] newtsv = new string[n][]; newtsv[0] = new string[1] { "# Plain text can not use comment line." }; // Make data for (int i = 1; i < n; ++i) { newtsv[i] = new string[5] { "" + (i * 5), "" + (i * 5 + 1), "" + (i * 5 + 2), "" + (i * 5 + 3), "" + (i * 5 + 4) }; } tsvio.plain = newtsv; path = Application.persistentDataPath + "/PlainWriteExample.tsv"; tsvio.SaveTo(path); AppendLog("Example TSV saved to " + path + "\nPlease check the written tsv!"); // If you want get only text from the KeypairText, // then call ToString () and be use the returned value. //string plainStr = tsvio.ToString (); // or tsvio.PlainToString () // Your customize (encrypt etc...) and your save method add to here. //plainStr = YourEncrypt (plainStr); //YourSave (plainStr); } }