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) { 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(); } } } }
/// <summary> /// Called on update, check to see if the state has changed sense the last call /// </summary> public override void OnUpdate(InteractableStates state, Interactable source) { if (state.CurrentState() != lastState) { // the state has changed, do something new lastState = state.CurrentState(); } }
/// <summary> /// Creates the default States ScriptableObject configured for Interactable /// </summary> /// <returns>Default Interactable States asset</returns> public static States GetDefaultInteractableStates() { States result = ScriptableObject.CreateInstance <States>(); InteractableStates allInteractableStates = new InteractableStates(); result.StateModelType = typeof(InteractableStates); result.StateList = allInteractableStates.GetDefaultStates(); result.DefaultIndex = 0; return(result); }
/// <summary> /// A state has changed /// </summary> public override void OnStateChange(InteractableStates state, Interactable source) { base.OnStateChange(state, source); if (Events.Count > 0) { if (Events[0].Receiver != null) { Events[0].Receiver.OnUpdate(state, source); } } }
/// <summary> /// .A state has changed /// </summary> public override void OnStateChange(InteractableStates state, Interactable source) { base.OnStateChange(state, source); for (int i = 0; i < Events.Count; i++) { if (Events[i].Receiver != null) { Events[i].Receiver.OnUpdate(state, source); } } }
/// <summary> /// click happened /// </summary> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { base.OnClick(state, source, pointer); if (Events.Count > 0) { if (Events[0].Receiver != null) { Events[0].Receiver.OnClick(state, source, pointer); } } }
public static States GetDefaultInteractableStates() { States result = CreateInstance <States>(); InteractableStates allInteractableStates = new InteractableStates(); result.StateType = Type.GetType(typeof(InteractableStates).AssemblyQualifiedName); result.StateOptions = InteractableTypeFinder.Find(candidateStateTypes, TypeRestriction.AllowBase); result.StateList = allInteractableStates.GetDefaultStates(); result.DefaultIndex = 0; return(result); }
/// <summary> /// voice command happened /// </summary> public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1) { base.OnVoiceCommand(state, source, command, index, length); if (Events.Count > 0) { if (Events[0].Receiver != null) { Events[0].Receiver.OnVoiceCommand(state, source, command, index, length); } } }
/// <inheritdoc /> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { int currentIndex = source.GetDimensionIndex(); if (currentIndex % 2 == 0) { OnDeselect.Invoke(); } else { uEvent.Invoke(); } }
/// <inheritdoc /> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { if (source.ButtonMode == SelectionModes.Toggle) { if (source.IsToggled) { OnSelect.Invoke(); } else { OnDeselect.Invoke(); } } }
/// <summary> /// click happened /// </summary> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { base.OnClick(state, source); if (Host != null) { if (showClicked != null) { Host.StopCoroutine(showClicked); showClicked = null; } showClicked = Host.StartCoroutine(ClickTimer(clickTime)); } clickCount++; SetOutput(); }
/// <summary> /// Called on update, check to see if the state has changed sense the last call /// </summary> public override void OnUpdate(InteractableStates state, Interactable source) { if (state.CurrentState() != lastState) { // the state has changed, do something new /* * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0; * * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; * * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0; * * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0; * * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0; * * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0; * * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0; * * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0; * * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0; * * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0; * * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0; * * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0; * * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0; * * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0; * * or: * * bool hasFocus = source.HasFocus; * bool hasPress = source.HasPress; */ lastState = state.CurrentState(); SetOutput(); } }
/// <summary> /// voice command called /// </summary> public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1) { base.OnVoiceCommand(state, source, command, index, length); lastVoiceCommand = command; if (Host != null) { if (showVoice != null) { Host.StopCoroutine(showVoice); showVoice = null; } showVoice = Host.StartCoroutine(VoiceTimer(clickTime)); } SetOutput(); }
/// <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 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 hasGrab = state.GetState(InteractableStates.InteractableStateEnum.Grab).Value > 0; if (hadGrab != hasGrab) { if (hasGrab) { uEvent.Invoke(); } else { OnRelease.Invoke(); } } hadGrab = hasGrab; }
public InteractableStates SetupLogic() { StateType = Type.GetType(AssemblyQualifiedName); InteractableStates stateLogic = (InteractableStates)Activator.CreateInstance(StateType, StateList[DefaultIndex]); List <State> stateListCopy = new List <State>(); for (int i = 0; i < StateList.Count; i++) { State state = new State(); state.ActiveIndex = StateList[i].ActiveIndex; state.Bit = StateList[i].Bit; state.Index = StateList[i].Index; state.Name = StateList[i].Name; state.Value = StateList[i].Value; stateListCopy.Add(state); } stateLogic.ImportStates(stateListCopy); return(stateLogic); }
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(); }
public override void OnUpdate(InteractableStates state, Interactable source) { bool changed = state.CurrentState() != lastState; bool hadDown = hasDown; hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0; if (changed && hasDown != hadDown) { if (hasDown) { uEvent.Invoke(); } else { OnRelease.Invoke(); } } lastState = state.CurrentState(); }
/// <summary> /// a state has changed /// </summary> public virtual void OnStateChange(InteractableStates state, Interactable source) { // the state has changed, do something new /* * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0; * * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0; * * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0; * * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0; * * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0; * * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0; * * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0; * * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0; * * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0; * * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0; * * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0; * * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0; * * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0; * * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.VoiceCommand).Value > 0; * * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0; */ }
/// <inheritdoc /> public virtual void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1) { // Voice Command Happened }
/// <summary> /// starts the StateManager /// </summary> protected virtual void SetupStates() { StateManager = States.SetupLogic(); }
/// <inheritdoc /> public virtual void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { // Click Happened }
/// <inheritdoc /> public override void OnUpdate(InteractableStates state, Interactable source) { // using onClick }
/// <summary> /// voice command called /// </summary> public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1) { base.OnVoiceCommand(state, source, command, index, length); PlayAudio(source); }
/// <summary> /// click happened /// </summary> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { base.OnClick(state, source); PlayAudio(source); }
/// <inheritdoc /> public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { uEvent.Invoke(); }