Click or drag to resize

InputStateFindFirst Method

[This is preliminary documentation and is subject to change.]

Namespace:  RavingBots.MultiInput
Assembly:  RavingBots.MultiInput (in RavingBots.MultiInput.dll) Version: 0.12
Syntax
C#
public bool FindFirst(
	out IDevice foundDevice,
	out IVirtualAxis foundAxis,
	Func<IDevice, IVirtualAxis, bool> predicate,
	IEnumerable<InputCode> axes
)

Parameters

foundDevice
Type: RavingBots.MultiInputIDevice
If this method returned true, set to the found device. Otherwise, set to null.
foundAxis
Type: RavingBots.MultiInputIVirtualAxis
If this method returned true, set to the found axis. Otherwise, set to null. You can check the axis code via Code property.
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.
axes
Type: System.Collections.GenericIEnumerableInputCode
Axes to search through.

Return Value

Type: Boolean
true if predicate returned true for at least one axis, false otherwise.
Examples
The following example shows how you can use this method to find first PadLeftTrigger or PadRightTrigger axis that reports a value of at least 0.5.
var state = FindObjectOfType<InputState>();
var axes = new List<InputCode> {
    InputCode.PadLeftTrigger,
    InputCode.PadRightTrigger
};
IDevice device;
VirtualAxis axis;
if (state.FindFirst(out device, out axis, v => v.Value >= 0.5f, axes)) {
    Debug.LogFormat("Found Value >= 0.5 on device {0}, axis {1}", device.Name, axis.Code);
} else {
    Debug.LogFormat("Value >= 0.5 not found");
}
See Also

Reference