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(); } } }
/// <inheritdoc /> public override void OnUpdate(InteractableStates state, Interactable source) { bool hadDown = hasDown; hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0; if (hasDown != hadDown) { if (hasDown) { isNear = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0; if (IsFilterValid()) { uEvent.Invoke(); } } else { if (IsFilterValid()) { OnRelease.Invoke(); } } } }
public override void OnUpdate(InteractableStates state, Interactable source) { //modifying this for only gazing and not clicking and holding with fingers //if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0 && !hasDown) if (state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0 && !hasDown) { hasDown = true; clickTimer = 0; } //else if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value < 1) else if (state.GetState(InteractableStates.InteractableStateEnum.Focus).Value < 1) { hasDown = false; } if (hasDown && clickTimer < HoldTime) { clickTimer += Time.deltaTime; if (clickTimer >= HoldTime) { 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(); }
/// <inheritdoc /> public override void OnUpdate(InteractableStates state, Interactable source) { bool hasGrab = state.GetState(InteractableStates.InteractableStateEnum.Grab).Value > 0; if (hadGrab != hasGrab) { if (hasGrab) { uEvent.Invoke(); } else { OnRelease.Invoke(); } } hadGrab = hasGrab; }
public override void OnUpdate(InteractableStates state, Interactable source) { bool hadTouch = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0; if (this.hadTouch != hadTouch) { if (hadTouch) { uEvent.Invoke(); } else { OnTouchEnd.Invoke(); } } this.hadTouch = hadTouch; }
/// <inheritdoc /> public override void OnUpdate(InteractableStates state, Interactable source) { bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; if (hadFocus != hasFocus) { if (hasFocus) { uEvent.Invoke(); } else { OnFocusOff.Invoke(); } } hadFocus = hasFocus; }
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(); }
public override void OnUpdate(InteractableStates state, Interactable source) { bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; float focusTime = source.gameObject.GetComponent <ButtonFocusTime>().GetFocusTime(); //if button is focused for focusTime seconds, change button's focus state to be false if (hasFocus && focusTimer < focusTime) { focusTimer += Time.deltaTime; if (focusTimer >= focusTime) { source.SetState(InteractableStates.InteractableStateEnum.Focus, false); } } else { focusTimer = 0; } bool changed = state.CurrentState() != lastState; if (hadFocus != hasFocus && changed) { if (hasFocus) { uEvent.Invoke(); } else { OnFocusOff.Invoke(); } } hadFocus = hasFocus; lastState = state.CurrentState(); }