study/first_study/Library/PackageCache/com.unity.inputsystem@02433b2481ab/Samples~/RebindingUI/InputActionExtensions.cs
jh04010421 739d49f1a0 Unity | 2026.01.20
수업 실습 파일
2026-01-20 11:01:57 +09:00

25 lines
901 B
C#

using System;
namespace UnityEngine.InputSystem.Samples.RebindUI
{
/// <summary>
/// Extension methods to reduce code bloat of this example.
/// </summary>
public static class InputActionExtensions
{
/// <summary>
/// Attempts to find an action binding using its binding ID (GUID).
/// </summary>
/// <param name="action">The action instance, may be null.</param>
/// <param name="bindingId">The binding ID (GUID) represented by a string.</param>
/// <returns>Zero-based index of the binding or -1 if not found.</returns>
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);
}
}
}