32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|