Example #1
0
    void Start()
    {
        // Loads the INI file then converts the INIContent to INIUnity.
        try
        {
            config = INIFile.Read(Application.dataPath + "/Packages/INISystem/Example/Script/example.ini").ToINIUnity();
        }
        catch (System.IO.FileNotFoundException ex)
        {
            INIFile.Write(ex.FileName, config);
        }
        // Gets the mainText from the ini file, if no entry is found return the default text.
        mainText = config.GetString("mainText", "General", "This is the default for mainText");
        // Gets the secondaryText from the ini file, if no entry is found return the default text.
        secondaryText = config.GetString("secondaryText", "General", "This is the default for secondaryText");
        // Gets the firstNumber from the ini file, if no entry is found, the default text is returned.
        firstNumber = config.GetInt("firstNumber", "General", 12);
        // Gets the secondNumber from the ini file, if no entry is found, the default text is returned.
        secondNumber = config.GetFloat("secondNumber", "General", 18.55f);

        // Gets Unity specific datatypes handled by the INIUnity class.
        HUDColor = config.GetColor("HUDColor", "Graphics", Color.white);
        Debug.Log(config.GetVector2("mapSize", "FirstLevel", new Vector2(10, 10)));
        Debug.Log(config.GetVector3("startLocation", "FirstLevel", new Vector3(10, 2, 10)));
        Debug.Log(config.GetQuaternion("startRotation", "FirstLevel", new Quaternion(0, 90, 0, 0)));
        foreach (var entry in config.elements)
        {
            Debug.Log("Element found: " + "Key: " + entry.Key + " Value: " + entry.Value);
        }
    }
Example #2
0
 void LoadLevelListFromIniFile()
 {
     try
     {
         levelList = INIFile.Read(Application.dataPath + "/Config/LevelList.ini").ToINIUnity();
     }
     catch (System.IO.FileNotFoundException ex)
     {
         INIFile.Write(ex.FileName, levelList);
     }
 }