This commit is contained in:
CortexCore
2024-11-03 16:42:23 +08:00
commit b125894cc3
5904 changed files with 1070129 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using System;
using System.Linq;
namespace BITKit
{
public static partial class InputSystemExtensions
{
public static bool JustPressed(this InputAction.CallbackContext self)
{
return self.interaction is null && self.started;
}
public static InputAction RegisterCallback(this InputAction self, Action<InputAction.CallbackContext> 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<InputAction.CallbackContext> action)
{
self.performed -= action;
self.started -= action;
self.canceled -= action;
return self;
}
}
}