public override void _Update() { base._Update(); if (IsActiveTargetingSource()) { AFocuser focuser = InputShellMap.Instance.inputSwitchLogic.GetFocuserForCurrentTargetingSource(); if (focuser != null && focuser.Cursor != null) { focuser.Cursor.gameObject.SetActive(currentTarget == null); } } bool prev = m_Select; m_Select = (this as ITargetingInputSource).IsSelectPressed(); if (prev != m_Select) { OnSelectChanged(this, m_Select); } prev = m_Menu; m_Menu = (this as ITargetingInputSource).IsMenuPressed(); if (prev != m_Menu) { OnMenuChanged(this, m_Menu); } }
void Update() { // Simulate manipulation events when on a platform that doesn't have GestureRecognizer. // TODO: Simulate navigation events? // Only do manipulation event simulation in editor, and should we do it on PC? if (Application.platform == RuntimePlatform.WindowsEditor /*|| Application.platform == RuntimePlatform.WindowsPlayer*/) { AFocuser focuser = GetFocuserForSource(InteractionSourceKind.Hand); // Use the head's position + forward, since the focuser ray might point to the locked focus Vector3 newPos = Veil.Instance.HeadTransform.position + Veil.Instance.HeadTransform.forward; if (InputShell.Instance.SelectButton.PressedOnce) { ManipulationStartedEvent(focuser, newPos, focuser.FocusRay); } else if (InputShell.Instance.SelectButton.pressed) { ManipulationUpdatedEvent(focuser, newPos, focuser.FocusRay); } else if (InputShell.Instance.SelectButton.ReleasedOnce) { ManipulationCompletedEvent(focuser, newPos, focuser.FocusRay); } } }
/// <summary> /// HoldCanceled event fires an message event upwards on the focus object for "HoldCanceled" /// and calls OnHoldCanceled for InteractibleObjects /// </summary> /// <param name="focuser"></param> /// <param name="ray"></param> private void HoldCanceledEvent(AFocuser focuser, Ray ray) { if (focuser != null) { GameObject focusObject = focuser.PrimeFocus; InteractionEventArgs eventArgs = new InteractionEventArgs(focuser, Vector3.zero, true, ray); if (focusObject != null) { focusObject.SendMessage("HoldCanceled", eventArgs, SendMessageOptions.DontRequireReceiver); SendEvent(OnHoldCanceled, focusObject, eventArgs); ReleaseFocus(focuser); } if (focuser.UIInteractibleFocus != null) { PointerEventData eventData = focuser.GetPointerData(); FocusManager.Instance.ExecuteUIFocusEvent(focuser.UIInteractibleFocus, eventData, ExecuteEvents.pointerUpHandler); eventData.selectedObject = null; eventData.pointerPress = null; eventData.eligibleForClick = false; } } }
private void AttachObject(AFocuser focuser) { m_InteractingFocus = focuser; gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); StartCoroutine("CarryObject"); m_bAttached = true; }
private void InteractionManager_SourceReleasedCallback(UnityEngine.XR.WSA.Input.InteractionSourceReleasedEventArgs eventArgs) { UnityEngine.XR.WSA.Input.InteractionSourceState state = eventArgs.state; AFocuser focuser = GetFocuserForSource(state.source.kind); OnReleasedEvent(focuser); }
/// <summary> /// Navigation Updated event fires an message event upwards on the focus object for "NavigationUpdated" /// and calls OnNavigationUpdated for InteractibleObjects /// </summary> /// <param name="focuser"></param> /// <param name="relativePosition"></param> /// <param name="ray"></param> private void NavigationUpdatedEvent(AFocuser focuser, Vector3 relativePosition, Ray ray) { IsNavigating = true; if (focuser != null) { GameObject focusObject = focuser.PrimeFocus; InteractionEventArgs eventArgs = new InteractionEventArgs(focuser, relativePosition, true, ray); if (focusObject != null) { focusObject.SendMessage("NavigationUpdated", eventArgs, SendMessageOptions.DontRequireReceiver); SendEvent(OnNavigationUpdated, focusObject, eventArgs); } WorldGraphicsRaycaster.RayEventData pointerEventData = focuser.GetPointerData() as WorldGraphicsRaycaster.RayEventData; if (pointerEventData.pointerDrag != null) { pointerEventData.delta = relativePosition; Vector2 curPos = pointerEventData.position; pointerEventData.CurrentAddition += relativePosition * pointerEventData.ScaleMultiplier; Vector3 offsetpos = pointerEventData.InitialDragHandPos + pointerEventData.CurrentAddition; pointerEventData.position = Camera.main.WorldToScreenPoint(offsetpos); FocusManager.Instance.ExecuteUIFocusEvent(pointerEventData.pointerDrag, pointerEventData, ExecuteEvents.dragHandler); pointerEventData.position = curPos; } } }
public InteractionEventArgs(AFocuser focuser, Vector3 pos, bool isRelative, Ray gazeRay) { this.Focuser = focuser; this.Position = pos; this.IsPosRelative = isRelative; this.GazeRay = gazeRay; }
/// <summary> /// Navigation Canceled event fires an message event upwards on the focus object for "NavigationCanceled" /// and calls OnNavigationCanceled for InteractibleObjects /// </summary> /// <param name="focuser"></param> /// <param name="relativePosition"></param> /// <param name="ray"></param> private void NavigationCanceledEvent(AFocuser focuser, Vector3 relativePosition, Ray ray) { IsNavigating = false; if (focuser != null) { GameObject focusObject = focuser.PrimeFocus; InteractionEventArgs eventArgs = new InteractionEventArgs(focuser, relativePosition, true, ray); if (focusObject != null) { focusObject.SendMessage("NavigationCanceled", eventArgs, SendMessageOptions.DontRequireReceiver); SendEvent(OnNavigationCanceled, focusObject, eventArgs); ReleaseFocus(focuser); } if (focuser.UIInteractibleFocus != null) { PointerEventData pointerEventData = focuser.GetPointerData(); FocusManager.Instance.ExecuteUIFocusEvent(focuser.UIInteractibleFocus, focuser.GetPointerData(), ExecuteEvents.endDragHandler); pointerEventData.pointerDrag = null; FocusManager.Instance.ExecuteUIFocusEvent(focuser.UIInteractibleFocus, focuser.GetPointerData(), ExecuteEvents.pointerUpHandler); pointerEventData.selectedObject = null; } } }
private void CheckLockFocus(AFocuser focuser) { if (bLockFocus) { LockFocus(focuser); } }
/// <summary> /// Gets the focuser tied to the current active input source. /// </summary> /// <returns></returns> public AFocuser GetFocuserForCurrentTargetingSource() { AFocuser focuser = null; if (FocusManager.Instance != null) { for (int index = 0; index < FocusManager.Instance.Focusers.Length; index++) { InputSourceFocuser sourceFocuser = FocusManager.Instance.Focusers[index] as InputSourceFocuser; if (sourceFocuser != null && sourceFocuser.TargetingInputSource == CurrentTargetingSource) { focuser = FocusManager.Instance.Focusers[index]; break; } } //If we haven't found a specific focuser use the gaze. if (focuser == null) { focuser = FocusManager.Instance.GazeFocuser; } } return(focuser); }
private void DetachObjects() { StopCoroutine("CarryObjects"); if (m_ParentObjects) { foreach (GameObject target in Targets) { target.layer = LayerMask.NameToLayer("Default"); target.transform.parent = null; } if (m_parent != null) { GameObject.Destroy(m_parent); } } else { foreach (GameObject target in Targets) { target.layer = LayerMask.NameToLayer("Default"); } } m_bAttached = false; m_InteractingFocus = null; }
private void AttachObjects(AFocuser focuser) { m_InteractingFocus = focuser; if (m_ParentObjects) { if (m_parent == null) { m_parent = new GameObject(); } foreach (GameObject target in Targets) { target.layer = LayerMask.NameToLayer("Ignore Raycast"); target.transform.parent = m_parent.transform; } } else { foreach (GameObject target in Targets) { target.layer = LayerMask.NameToLayer("Ignore Raycast"); } } StartCoroutine("CarryObjects"); m_bAttached = true; }
void OnShellSelectEvent(InputSourceBase inputSource, bool newState) { AFocuser focuser = InputSourceFocuser.GetFocuserForInputSource(inputSource); if (focuser != null) { if (newState) { if (inputSource != InputSources.Instance.hands) // && inputSource != InputSources.Instance.fawkes) { OnPressedEvent(focuser); // Need to track hold time before firing this HoldStartedEvent(focuser, focuser.FocusRay); } } else { if (inputSource != InputSources.Instance.hands) // && inputSource != InputSources.Instance.fawkes) { OnReleasedEvent(focuser); // Only fire this if HoldStarted was fired HoldCompletedEvent(focuser, focuser.FocusRay); // Need to only fire this if hold wasn't started? TappedEvent(focuser, focuser.FocusRay); } } } }
private void DetachObject() { StopCoroutine("CarryObject"); gameObject.layer = LayerMask.NameToLayer("Default"); m_bAttached = false; m_InteractingFocus = null; }
private void ReleaseFocus() { if (_selectingFocuser != null) { _selectingFocuser.ReleaseFocus(); _selectingFocuser = null; } }
private void LockFocus(AFocuser focuser) { if (focuser != null) { ReleaseFocus(focuser); focuser.LockFocus(); } }
private void ReleaseFocus(AFocuser focuser) { if (focuser != null) { focuser.ReleaseFocus(); focuser = null; } }
private void LockFocus(AFocuser focuser) { if (focuser != null) { ReleaseFocus(); _selectingFocuser = focuser; _selectingFocuser.LockFocus(); } }
protected override void OnNavigationCanceled(GameObject obj, InteractionManager.InteractionEventArgs eventArgs) { if (eventArgs.Focuser == m_Focuser) { StopCoroutine("RotateObject"); m_Focuser.ReleaseFocus(); m_Focuser = null; } }
void OnShellScrollEvent() { AFocuser focuser = InputShellMap.Instance.inputSwitchLogic.GetFocuserForCurrentTargetingSource(); if (focuser != null && focuser.PrimeFocus != null) { focuser.PrimeFocus.SendMessage("OnScroll", null, SendMessageOptions.DontRequireReceiver); } }
private void NavigationCanceledCallback(InteractionSourceKind source, Vector3 relativePosition, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { NavigationCanceledEvent(focuser, relativePosition, ray); } }
private void ManipulationCompletedCallback(InteractionSourceKind source, Vector3 position, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { ManipulationCompletedEvent(focuser, position, ray); } }
private void ManipulationCanceledCallback(UnityEngine.XR.WSA.Input.InteractionSourceKind source, Vector3 position, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { ManipulationCanceledEvent(focuser, position, ray); } }
private void HoldCanceledCallback(UnityEngine.XR.WSA.Input.InteractionSourceKind source, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { HoldCanceledEvent(focuser, ray); } }
private void HoldCompletedCallback(InteractionSourceKind source, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { HoldCompletedEvent(focuser, ray); } }
private void NavigationCompletedCallback(UnityEngine.XR.WSA.Input.InteractionSourceKind source, Vector3 relativePosition, Ray ray) { AFocuser focuser = GetFocuserForSource(source); if (focuser != null) { NavigationCompletedEvent(focuser, relativePosition, ray); } }
/// <summary> /// Present the default keyboard to the camera. /// </summary> public void PresentKeyboard(AFocuser focuser) { this.gameObject.SetActive(true); m_Focuser = focuser; ActivateSpecificKeyboard(LayoutType.Alpha); onPlacement(this, EventArgs.Empty); }
protected override void OnNavigationStarted(GameObject obj, InteractionManager.InteractionEventArgs eventArgs) { if (m_Focuser != null) { m_Focuser = eventArgs.Focuser; m_handOrigin = eventArgs.Position; m_Focuser.LockFocus(); StartCoroutine("RotateObject"); } }
public Ray GetRayForScreenPos(Vector2 pos) { AFocuser focus = FocusManager.Instance.GazeFocuser; Ray newRay = focus.FocusRay; float vFov = 0.5f * Mathf.Sin(Mathf.Deg2Rad * Veil.Instance.DeviceFOV); float hFov = 0.5f * Mathf.Sin(Mathf.Deg2Rad * (Veil.Instance.DeviceFOV * Veil.c_horiz_ratio)); newRay.direction += (focus.TargetOrientation * Vector3.up) * pos.y * vFov + (focus.TargetOrientation * Vector3.right) * pos.x * hFov; return(newRay); }
void OnReleasedEvent(AFocuser focuser) { GameObject focusObject = focuser.PrimeFocus; InteractionEventArgs eventArgs = new InteractionEventArgs(focuser, Vector3.zero, true, focuser.FocusRay); if (focusObject != null) { focusObject.SendMessage("Released", eventArgs, SendMessageOptions.DontRequireReceiver); SendEvent(OnReleased, focusObject, eventArgs); ReleaseFocus(focuser); } }