UPdate
This commit is contained in:
@@ -9,6 +9,51 @@ namespace OnlyScove.Scripts
|
||||
[SerializeField] private InputActionAsset inputActions;
|
||||
public InputActionAsset InputActions => inputActions;
|
||||
|
||||
private const string REBINDS_KEY = "InputRebinds";
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (inputActions != null)
|
||||
{
|
||||
LoadBindings();
|
||||
inputActions.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (inputActions != null)
|
||||
{
|
||||
inputActions.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveBindings()
|
||||
{
|
||||
if (inputActions == null) return;
|
||||
string rebinds = inputActions.SaveBindingOverridesAsJson();
|
||||
PlayerPrefs.SetString(REBINDS_KEY, rebinds);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public void LoadBindings()
|
||||
{
|
||||
if (inputActions == null) return;
|
||||
string rebinds = PlayerPrefs.GetString(REBINDS_KEY, string.Empty);
|
||||
if (!string.IsNullOrEmpty(rebinds))
|
||||
{
|
||||
inputActions.LoadBindingOverridesFromJson(rebinds);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetBindings()
|
||||
{
|
||||
if (inputActions == null) return;
|
||||
inputActions.RemoveAllBindingOverrides();
|
||||
PlayerPrefs.DeleteKey(REBINDS_KEY);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
// Continuous Inputs
|
||||
public virtual Vector2 MoveInput { get; protected set; }
|
||||
public virtual Vector2 LookInput { get; protected set; }
|
||||
|
||||
Reference in New Issue
Block a user