Files
TowerDefence/My project/Library/PackageCache/com.unity.inputsystem@be6c4fd0abf5/Samples~/RebindingUI/RebindSaveLoad.cs
Caleb Sandford deQuincey 334021d04e Started project
2025-11-14 17:30:41 +00:00

21 lines
487 B
C#

using UnityEngine;
using UnityEngine.InputSystem;
public class RebindSaveLoad : MonoBehaviour
{
public InputActionAsset actions;
public void OnEnable()
{
var rebinds = PlayerPrefs.GetString("rebinds");
if (!string.IsNullOrEmpty(rebinds))
actions.LoadBindingOverridesFromJson(rebinds);
}
public void OnDisable()
{
var rebinds = actions.SaveBindingOverridesAsJson();
PlayerPrefs.SetString("rebinds", rebinds);
}
}