1
This commit is contained in:
@@ -36,6 +36,19 @@ namespace BITKit
|
||||
action.RegisterCallback(callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputActionGroup RegisterCallback(InputAction inputAction,Action<InputAction.CallbackContext> callback)
|
||||
{
|
||||
EnsureConfiguration();
|
||||
|
||||
var action = actions.GetOrAdd(inputAction.name, _=>inputAction.Clone());
|
||||
|
||||
allowInput.Invoke();
|
||||
|
||||
action.RegisterCallback(callback);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputAction EnsureCreated(InputActionReference reference)
|
||||
{
|
||||
@@ -57,6 +70,20 @@ namespace BITKit
|
||||
|
||||
return action;
|
||||
}
|
||||
public InputAction EnsureCreated(InputAction inputAction)
|
||||
{
|
||||
EnsureConfiguration();
|
||||
var action = actions.GetOrAdd(inputAction.name, _ =>
|
||||
{
|
||||
var newAction = inputAction.Clone();
|
||||
newAction.Rename(inputAction.name);
|
||||
return newAction;
|
||||
});
|
||||
|
||||
allowInput.Invoke();
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
public void Inherit(InputActionGroup other)
|
||||
{
|
||||
@@ -80,6 +107,12 @@ namespace BITKit
|
||||
action.UnRegisterCallback(callback);
|
||||
}
|
||||
|
||||
public void UnRegisterCallback(InputAction inputAction, Action<InputAction.CallbackContext> callback)
|
||||
{
|
||||
if(actions.TryGetValue(inputAction.name,out var action))
|
||||
action.UnRegisterCallback(callback);
|
||||
}
|
||||
|
||||
private void EnsureConfiguration()
|
||||
{
|
||||
if (state is not InitializationState.Initialized)
|
||||
|
Reference in New Issue
Block a user