public void Save(PlayerInfo info)
    {
        PlayerInfo pInfo = new PlayerInfo
        {
            name   = info.name,
            score  = info.score,
            mobile = info.mobile,
        };

        Debug.Log(pInfo.name + " | " + pInfo.score);


        masterPlayerInfoList.Add(pInfo);
        playerInfoList.Add(pInfo);
        // Sort the list in game

        masterPlayerInfoList = Sort(masterPlayerInfoList);
        playerInfoList       = Sort(playerInfoList);

        string jsonStr       = JsonArrayUtility.ToJson(playerInfoList, true);
        string masterJsonStr = JsonArrayUtility.ToJson(masterPlayerInfoList, true);

        // Write to file by date
        JsonFileUtility.WriteJsonToFile(FOLDER_PATH + "/" + FILENAME, jsonStr, JSONSTATE.PERSISTENT_DATA_PATH);
        // Write to master file
        JsonFileUtility.WriteJsonToFile(FOLDER_PATH + "/" + MASTER_FILENAME, masterJsonStr, JSONSTATE.PERSISTENT_DATA_PATH);
        //Debug.Log("Saving leaderboard " + jsonStr);

        //if(AppManager.Instance.uiManager.useLocalLeaderboard)
        leaderboardDisplay.PopulateData(playerInfoList);
    }
    public void SaveJson()
    {
        saveObj = CreateAdminSave();

        string saveJsonString = JsonUtility.ToJson(saveObj, true);

        JsonFileUtility.WriteJsonToFile(ADMINSAVEFILE, saveJsonString, JSONSTATE.PERSISTENT_DATA_PATH);
        Debug.Log("Saving as JSON " + saveJsonString);
    }
예제 #3
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);
    }
    public void AddPlayerInfo(LocalPlayerInfoJson pInfo)
    {
        newlyAdded = pInfo;
        data.Add(pInfo);

        string saveJsonStr = JsonArrayUtility.ToJson(data, true);

        JsonFileUtility.WriteJsonToFile(SAVEFILENAME, saveJsonStr, JSONSTATE.PERSISTENT_DATA_PATH);
        Debug.Log("Saving as JSON " + saveJsonStr);

        Sort();
    }