using System;
namespace UnityEngine.InputSystem.Samples.RebindUI
{
///
/// Extension methods to reduce code bloat of this example.
///
public static class InputActionExtensions
{
///
/// Attempts to find an action binding using its binding ID (GUID).
///
/// The action instance, may be null.
/// The binding ID (GUID) represented by a string.
/// Zero-based index of the binding or -1 if not found.
public static int FindBindingById(this InputAction action, string bindingId)
{
if (action == null || string.IsNullOrEmpty(bindingId))
return -1;
var id = new Guid(bindingId);
return action.bindings.IndexOf(x => x.id == id);
}
}
}