コード例 #1
0
ファイル: Keybinds.cs プロジェクト: deankeinan/FantasySim
        public void SaveKeybinds()
        {
            // Create a new Saved_Keybinds.
            Saved_Keybinds data = new Saved_Keybinds();

            // Save the data.
            data.savedInventoryKeyCode = inventoryKeyCode;
            data.savedActionKeyCode    = actionKeyCode;
            // Turn the Saved_Keybinds data to Json data.
            string keybindsToJson = JsonUtility.ToJson(data);

            // Save the information.
            PlayerPrefs.SetString("Keybinds", keybindsToJson);
        }
コード例 #2
0
ファイル: Keybinds.cs プロジェクト: deankeinan/FantasySim
        public void LoadKeybinds()
        {
            // Load the json data.
            string keybindsJson = PlayerPrefs.GetString("Keybinds");

            // IF we dont have saved information.
            if (String.IsNullOrEmpty(keybindsJson))
            {
                // Lets reset to our defaults.
                ResetToDefaults();
                // We leave.
                return;
            }

            // Turn the json data to the data to represent Saved_Keybinds.
            Saved_Keybinds data = JsonUtility.FromJson <Saved_Keybinds> (keybindsJson);

            // Load our KeyBinds.
            SetLoadedKeyBinds(data.savedInventoryKeyCode, inventoryKeyCode);
            SetLoadedKeyBinds(data.savedActionKeyCode, actionKeyCode);
        }