using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using System; using System.Linq; using UnityEngine.InputSystem.Controls; namespace BITKit { public static partial class InputSystemExtensions { public static bool JustPressed(this InputAction.CallbackContext self) { return self is { started:true, control: ButtonControl { wasPressedThisFrame: true , isPressed:true} }; } public static InputAction RegisterCallback(this InputAction self, Action action) { self.performed += action; self.started += action; self.canceled += action; return self; } public static string GetKeyMap(this InputAction self) { return string.Join("|", self.bindings.Select(x=>x.path.Split("/").Last().ToUpper())); } public static string GetKeyMap(this InputActionReference self) { return string.Join("|", self.action.bindings.Select(x=>x.path.Split("/").Last().ToUpper())); } public static InputAction UnRegisterCallback(this InputAction self, Action action) { self.performed -= action; self.started -= action; self.canceled -= action; return self; } } }