InputStateExtFindFirst Method (InputState, FuncIDevice, IVirtualAxis, Boolean) |
[This is preliminary documentation and is subject to change.]
Namespace:
RavingBots.MultiInput
Assembly:
RavingBots.MultiInput (in RavingBots.MultiInput.dll) Version: 0.12
Syntax public static IDevice FindFirst(
this InputState state,
Func<IDevice, IVirtualAxis, bool> predicate
)
Parameters
- state
- Type: RavingBots.MultiInputInputState
InputState instance. - predicate
- Type: SystemFuncIDevice, IVirtualAxis, Boolean
Predicate for the search. Takes a IDevice object, an instance of IVirtualAxis
that belongs to that device, and should return true if said axis reports a value that interests you.
Return Value
Type:
IDeviceFound device, or
null if none were found.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
InputState. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Examples
The following example shows how you can use this method to find first device that reports
a value of at least 0.5 on any axis.
var state = FindObjectOfType<InputState>();
var device = state.FindFirst(a => a.Value >= 0.5f);
if (device != null) {
Debug.LogFormat("Found Value >= 0.5 on device {0}", device.Name);
} else {
Debug.LogFormat("Value >= 0.5 not found");
}
See Also