quakeball/Assets/Scripts/Util/PressedActionDisplayer.cs

32 lines
1.1 KiB
C#
Raw Normal View History

2020-08-07 00:43:30 +02:00
using UnityEngine;
using UnityEngine.InputSystem;
namespace NeonTea.Quakeball.Util {
public class PressedActionDisplayer : MonoBehaviour {
private InputAction Initializer;
private InputAction AnyAction;
private InputActionRebindingExtensions.RebindingOperation Rebinding;
private void Awake() {
AnyAction = new InputAction("InputAction displayer", binding: "*/*");
Initializer = new InputAction("Display the next InputAction", binding: "<Keyboard>/f1");
Initializer.Enable();
Initializer.performed += _ => {
Debug.Log("Waiting for InputAction to display...");
Rebinding = AnyAction.PerformInteractiveRebinding().Start();
};
}
private void Update() {
if (Rebinding != null && Rebinding.completed) {
string Binding = Rebinding.action.ToString();
int Index = Binding.IndexOf("/") + 1;
Debug.Log(Binding.Substring(Index, Binding.Length - Index - 1));
Rebinding = null;
}
}
}
}