public void AddEvents(Func <bool> onPressEvent = null, Func <bool> onHoldEvent = null, Func <bool> onReleaseEvent = null, InvokeSet pressFunc = null, InvokeSet holdFunc = null, InvokeSet releaseFunc = null) { if (onPressEvent != null) { AddPress(onPressEvent); } if (onHoldEvent != null) { AddHold(onHoldEvent); } if (onReleaseEvent != null) { AddRelease(onReleaseEvent); } if (pressFunc != null) { AddPress(pressFunc); } if (holdFunc != null) { AddHold(holdFunc); } if (releaseFunc != null) { AddRelease(releaseFunc); } }
public void AddPress(InvokeSet a) { if (onPress == null) { onPress = new UnityEvent(); } a.Bind(onPress); }
public void AddRelease(InvokeSet a) { if (onRelease == null) { onRelease = new UnityEvent(); } a.Bind(onRelease); }
public void AddHold(InvokeSet a) { if (onHold == null) { onHold = new UnityEvent(); } a.Bind(onHold); }
public void AddKeyCombinations(KCombination[] keyCombo, string nameToUse, Func <bool> onPress = null, Func <bool> onHold = null, Func <bool> onRelease = null, InvokeSet setPress = null, InvokeSet setHold = null, InvokeSet setRelease = null) { if (keyCombo != null) { AddComplexKeyPresses(keyCombo); } if (string.IsNullOrEmpty(name)) { name = nameToUse; } keyEvent.AddEvents(onPress, onHold, onRelease, setPress, setHold, setRelease); }
/// <summary> /// describes functions to execute when any of the specified key-combinations are pressed/held/released /// </summary> public KBind(KCombination[] kCombos, string name = null, Func <bool> onPressEvent = null, Func <bool> onHoldEvent = null, Func <bool> onReleaseEvent = null, Func <bool> additionalRequirement = null, bool eventAlwaysTriggerable = false, InvokeSet pressFunc = null, InvokeSet holdFunc = null, InvokeSet releaseFunc = null) { keyCombinations = kCombos; Init(); Array.Sort(keyCombinations); Array.Reverse(keyCombinations); // put least complex key bind first, backwards from usual processing this.name = name; keyEvent.AddEvents(onPressEvent, onHoldEvent, onReleaseEvent, pressFunc, holdFunc, releaseFunc); if (additionalRequirement != null) { this.additionalRequirement = additionalRequirement; } this.eventAlwaysTriggerable = eventAlwaysTriggerable; }
/// <summary> /// describes functions to execute when a specific key-combination is pressed/held/released /// </summary> public KBind(KCombination kCombo, string name = null, Func <bool> onPressEvent = null, Func <bool> onHoldEvent = null, Func <bool> onReleaseEvent = null, Func <bool> additionalRequirement = null, bool eventAlwaysTriggerable = false, InvokeSet pressFunc = null, InvokeSet holdFunc = null, InvokeSet releaseFunc = null) : this(new[] { kCombo }, name, onPressEvent, onHoldEvent, onReleaseEvent, additionalRequirement, eventAlwaysTriggerable, pressFunc, holdFunc, releaseFunc) { }