public override void OnUpdate(InteractableStates state, Interactable source) { if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0 && !hasDown) { hasDown = true; clickTimer = 0; } else if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value < 1) { hasDown = false; } Debug.Log(HoldTime); if (hasDown && clickTimer < HoldTime) { clickTimer += Time.deltaTime; if (clickTimer >= HoldTime) { Debug.Log("Hold!!"); uEvent.Invoke(); } } }
public override void OnUpdate(InteractableStates state, Interactable source) { bool changed = state.CurrentState() != lastState; bool hadDown = hasDown; hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0; bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; if (changed && hasDown != hadDown && focused) { if (hasDown) { uEvent.Invoke(); } else { OnRelease.Invoke(); } } lastState = state.CurrentState(); }
public override void OnUpdate(InteractableStates state, Interactable source) { bool changed = state.CurrentState() != lastState; bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; if (hadFocus != hasFocus && changed) { if (hasFocus) { uEvent.Invoke(); } else { OnFocusOff.Invoke(); } } hadFocus = hasFocus; lastState = state.CurrentState(); }