Net-Game/Library/PackageCache/com.unity.inputsystem@e2c83221d2dc/Samples~/RebindingUI/RebindSaveLoad.cs
2025-03-28 08:33:16 -04: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);
}
}