示例#1
0
    //Loads game data
    public void LoadFromDisc()
    {
        Debug.Log("PlayerInputManager: Loading data from disk, " + DataSaveHandler.getPlayerControlsFile());
        CheckIfMainFolderExists();

        //Find save
        string filePath = DataSaveHandler.getPlayerControlsFile();

        if (File.Exists(filePath))
        {
            Debug.Log("PlayerInputManager: Data file exists " + filePath);

            //Read JSON
            string dataAsJson = File.ReadAllText(filePath);

            Debug.Log(dataAsJson);

            //Convert JSON to data object
            SetCurrentKeybindHolder(JsonUtility.FromJson <InputActionHolder> (dataAsJson));
        }
        else
        {
            Debug.Log("PlayerInputManager: Data file not found, creating new and saving to: " + DataSaveHandler.getPlayerControlsFile());
            SetCurrentKeybindHolder(new InputActionHolder());
            SaveToDisc();
        }
    }
示例#2
0
    //Saves game data
    public void SaveToDisc()
    {
        Debug.Log("PlayerInputManager: Saving data to disk, " + DataSaveHandler.getPlayerControlsFile());
        CheckIfMainFolderExists();

        //Convert to JSON
        string dataAsJson = JsonUtility.ToJson(getInputActions(), true);

        //Save data
        File.WriteAllText(DataSaveHandler.getPlayerControlsFile(), dataAsJson);
    }