示例#1
0
    void SaveSettings()
    {
        TraininglobalSettings save = CreateTrainingSaveFile();
        string jsonStr             = JsonUtility.ToJson(save, true);

        JsonFileUtility.WriteJsonToFile(SAVEFILENAME, jsonStr, JSONSTATE.PERSISTENT_DATA_PATH);

        Debug.Log("Saving as JSON " + jsonStr);
    }
示例#2
0
    TraininglobalSettings CreateTrainingSaveFile()
    {
        TraininglobalSettings saveTraininglobalSettings = new TraininglobalSettings
        {
            //trainingStarted = TrinaxGlobal.Instance.traininglobalSettings.trainingStarted,
            infiniteLife = traininglobalSettings.infiniteLife,
            minSpawnTime = traininglobalSettings.minSpawnTime,
            maxSpawnTime = traininglobalSettings.maxSpawnTime,
            difficulty   = traininglobalSettings.difficulty,
        };

        return(saveTraininglobalSettings);
    }
示例#3
0
    void LoadSettings()
    {
        string jsonStr = JsonFileUtility.LoadJsonFromFile(SAVEFILENAME, JSONSTATE.PERSISTENT_DATA_PATH);

        TraininglobalSettings loadObj = JsonUtility.FromJson <TraininglobalSettings>(jsonStr);

        if (loadObj != null)
        {
            traininglobalSettings.infiniteLife = loadObj.infiniteLife;
            traininglobalSettings.minSpawnTime = loadObj.minSpawnTime;
            traininglobalSettings.maxSpawnTime = loadObj.maxSpawnTime;
        }
        else
        {
            Debug.Log("Json file is empty! Creating a new training save file...");
            loadObj = CreateTrainingSaveFile();
        }
    }