示例#1
0
        public void Initialize()
        {
            const string fileName = "SystemSetting";

#if !UNITY_EDITOR
            var path = Path.Combine(Application.persistentDataPath, fileName + ".ini");
            if (!File.Exists(path))
            {
                using (var asset = AssetService.Get().Load($"Config/{fileName}", typeof(TextAsset))) {
                    File.WriteAllText(path, asset.GetTextAsset().text);
                }
            }

            using (var reader = new StreamReader(path)) {
                SystemSetting = IniRead.Parse(reader);
            }
#else
            using (var asset = AssetService.Get().Load($"Config/{fileName}", typeof(TextAsset))) {
                using (var reader = new StringReader(asset.GetTextAsset().text)) {
                    SystemSetting = IniRead.Parse(reader);
                }
            }
#endif

            IniRead.SystemSetting = SystemSetting;
        }
示例#2
0
        public void ReadingFile()
        {
            var Reader = IniRead.Parse(@"C:\data\Projects\ini_read\ini\test.ini");

            bool testbool = Reader.GetBool("user", "active");

            Debug.WriteLine("bool value " + testbool);
            Assert.IsTrue(testbool == true);

            testbool = Reader.GetBool("kek", "for");
            Debug.WriteLine("bool value " + testbool);
            Assert.IsTrue(testbool == true);

            string teststring = Reader.GetString("kek", "want");

            Debug.WriteLine("string value " + teststring);
            Assert.IsTrue(teststring == "connect");

            double testdouble = Reader.GetDouble("user", "pi");

            Debug.WriteLine("double value " + testdouble);
            Assert.IsTrue(testdouble == 3.14159);

            int testint = Reader.GetInt("kek", "hilarious");

            Debug.WriteLine("int value " + testint);
            Assert.IsTrue(testint == 3);
        }