40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
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;
|
|
}
|
|
}
|
|
} |