private void CheckStopFillingSlider(ERayOrigin rayOrigin) { if (_isFilling && rayOrigin == _handFilling) { HandleUp(); } }
/// <summary> /// Method called when the user release the slider bar /// </summary> private void HandleUp() { // If the bar was filled and the user is releasing it, we invoke the OnBarReleased event if (_barFilled) { _barFilled = false; OnBarReleased?.Invoke(); } // If the coroutine has been started (and thus we have a reference to it) stop it. if (_fillBarRoutine != null) { StopCoroutine(_fillBarRoutine); _fillBarRoutine = null; } // Reset the timer and bar values. if (!ValueIsGoingDown && ResetFillOnRelease) { Timer = 0f; value = 0.0f; } // Set the Hand filling at null _handFilling = ERayOrigin.NONE; _isFillingWithMesh = false; }
/// <summary> /// Event raised when an object is hovered by the laser. /// </summary> /// <param name="raycastOrigin">The Origin of the ray that just hovered something</param> /// <param name="objectHovered">The GameObject that was just hovered by the user (must have a collider)</param> public OnObjectIsBeingHovered(ERayOrigin raycastOrigin, GameObject objectHovered) : base("Event raised when an object is hovered by the laser.") { RaycastOrigin = raycastOrigin; HoveredObject = objectHovered; FireEvent(this); }
/// <summary> /// Event called when the user is clicking on something /// </summary> /// <param name="clickEvent">The event raised when something is clicked</param> void CheckRectClick(ObjectWasClickedEvent clickEvent) { if (clickEvent.ObjectClicked == transform && _rayHoldingHandle == ERayOrigin.NONE) { _rayHoldingHandle = clickEvent.RayOrigin; } }
private void CheckCanFillSlider(GameObject toCheck, ERayOrigin raycastOrigin) { if (interactable && toCheck == gameObject) { HandleHandInteracting(raycastOrigin); } }
public OnLaserLengthChanged(ERayOrigin lasersOrigin, float3 newEndPos) : base("The base event to raise when one of the laserPointer changed its length.") { LaserOrigin = lasersOrigin; NewEndPos = newEndPos; FireEvent(this); }
public OnLaserWidthChanged(ERayOrigin laserOrigin, float newWidth) : base("The base event to raise when one of the laserPointer changed its width.") { LaserOrigin = laserOrigin; NewWidth = newWidth; FireEvent(this); }
/// <summary> /// Event called when the user is clicking on something /// </summary> /// <param name="clickEvent">The event raised when an object is clicked</param> private void CheckBarClick(ObjectWasClickedEvent clickEvent) { if (interactable && clickEvent.ObjectClicked == transform && _rayHoldingHandle == ERayOrigin.NONE) { _rayHoldingHandle = clickEvent.RayOrigin; } }
/// <summary> /// Handle the raycastHits to check if one of them touch something /// </summary> private void HandleOver(RaycastHitVariable hitVar, ERayOrigin origin) { GameObject currentHoveredObject = HoveringVariablesContainer.GetCurrentHit(origin); //If nothing is hit and something was previously hovered, we raise the stop hovering event if (hitVar.IsNull && currentHoveredObject != null) { new OnStopHoveringObject(origin, currentHoveredObject); } //If something is hit else if (!hitVar.IsNull && hitVar.Value.collider != null) { var objectHit = hitVar.Value.collider.gameObject; // Event raised only when a new object is hovered if (currentHoveredObject == null) { new OnStartHoveringObject(origin, objectHit); } // If the user started to hover a new object else if (objectHit != currentHoveredObject) { // We tell the system that we stopped hovering the current object. // The Systems will then be notify on the next frame that something new is being hovered new OnStopHoveringObject(origin, currentHoveredObject); } // If we're still hovering the same object as the previous frame else { new OnObjectIsBeingHovered(origin, currentHoveredObject); } } }
/// <summary> /// Event raised when an object is being clicked using the VR Clicker Systems /// </summary> /// <param name="rayOrigin">The Origin of the ray that just clicked something</param> /// <param name="objectClicked">The GameObject that is being clicked by the user (must have a collider)</param> public OnVRClickerIsClicking(ERayOrigin rayOrigin, GameObject objectClicked) : base("Event raised when an object is being clicked using the VR Clicker Systems.") { RaycastOrigin = rayOrigin; ClickedObject = objectClicked; FireEvent(this); }
public ObjectWasClickedEvent(ERayOrigin rayOrigin, Transform objectClicked) : base("Event raised when an object is clicked with the Trigger.") { RayOrigin = rayOrigin; ObjectClicked = objectClicked; FireEvent(this); }
public static void SetInteractionVariables(ERayOrigin rayOrigin, Vector3 hitPoint, GameObject currentHit) { switch (rayOrigin) { case ERayOrigin.RIGHT_HAND: _currentRightHitPosition = hitPoint; _currentRightHit = currentHit; _isOverSomethingRight = currentHit != null; break; case ERayOrigin.LEFT_HAND: _currentLeftHitPosition = hitPoint; _currentLeftHit = currentHit; _isOverSomethingLeft = currentHit != null; break; case ERayOrigin.CAMERA: _currentGazeHitPosition = hitPoint; _currentGazeHit = currentHit; _isOverSomethingGaze = currentHit != null; break; default: throw new System.Exception(); } }
void Awake() { _lineRenderer = GetComponent <LineRenderer>(); // VRRaycastAuthoring is necessaraly on this GameObject; as the LaserPointerStateAuthoring needs it. _rayOrigin = GetComponent <VRRaycastAuthoring>().RayOrigin; OnLaserLengthChanged.Listeners += UpdateLineRender; OnSetupVRReady.RegisterSetupVRResponse(InitPositionOffset); }
/// <summary> /// Event raised when an object was being clicked and is not anymore, using the VR Clicker system /// </summary> /// <param name="rayOrigin">The Origin of the ray that just clicked something</param> /// <param name="unclickedObject">The GameObject that was unclicked by the user (must have a collider))</param> public OnVRClickerStopClicking(ERayOrigin rayOrigin, GameObject unclickedObject) : base("Event raised when an object was being clicked and is not anymore, using the VR Clicker system.") { RaycastOrigin = rayOrigin; UnclickedObject = unclickedObject; VRClickerVariablesContainer.SetCurrentClickedVariables(rayOrigin, null, false); FireEvent(this); }
/// <summary> /// Check which hand is pointing toward the slider /// </summary> private void HandleHandInteracting(ERayOrigin handPointing) { _handFilling = handPointing; if (_handFilling != ERayOrigin.NONE && _fillBarRoutine == null) { _fillBarRoutine = StartCoroutine(FillBar()); } }
/// <summary> /// Check which hand is pointing toward the slider /// </summary> private void HandleHandInteracting(ERayOrigin handPointing) { if (_isFilling) { return; } _handFilling = handPointing; _isFilling = true; UIHapticGenerator.CreateClickHapticSignal(handPointing); }
public static void CreateClickHapticSignal(ERayOrigin rayOrigin) { if (rayOrigin == ERayOrigin.LEFT_HAND) { new OnHapticRequestedEvent(EHand.LEFT, 0.2f, 0.1f); } else if (rayOrigin == ERayOrigin.RIGHT_HAND) { new OnHapticRequestedEvent(EHand.RIGHT, 0.2f, 0.1f); } }
public ObjectWasHoveredEvent(ERayOrigin raycastOrigin, Transform objectHovered) : base("Event raised when an object is hovered by the laser.") { // We set the object that was Hovered as the selected gameObject if (objectHovered != null && objectHovered.GetComponent <UnityEngine.UI.Selectable>() != null) { EventSystem.current.SetSelectedGameObject(objectHovered.gameObject); } RaycastOrigin = raycastOrigin; ObjectHovered = objectHovered; FireEvent(this); }
public static float3 GetCurrentHitPosition(ERayOrigin rayOrigin) { switch (rayOrigin) { case ERayOrigin.RIGHT_HAND: return(_currentRightHitPosition); case ERayOrigin.LEFT_HAND: return(_currentLeftHitPosition); case ERayOrigin.CAMERA: return(_currentGazeHitPosition); default: throw new System.Exception(); } }
public static bool GetIsOverSomething(ERayOrigin rayOrigin) { switch (rayOrigin) { case ERayOrigin.RIGHT_HAND: return(_isOverSomethingRight); case ERayOrigin.LEFT_HAND: return(_isOverSomethingLeft); case ERayOrigin.CAMERA: return(_isOverSomethingGaze); default: throw new System.Exception(); } }
public static GameObject GetCurrentHit(ERayOrigin rayOrigin) { switch (rayOrigin) { case ERayOrigin.RIGHT_HAND: return(_currentRightHoveredObject); case ERayOrigin.LEFT_HAND: return(_currentLeftHoveredObject); case ERayOrigin.CAMERA: return(_currentGazeHoveredObject); default: throw new System.Exception(); } }
/// <summary> /// Event raised when the user was hovering somethinf with a VR Raycaster, and just stop hovering it /// </summary> /// <param name="raycastOrigin">The Origin of the ray that just hovered something</param> /// <param name="unhoveredObject">The GameObject that was hovered by the user, but isn't anymore (must have a collider)</param> public OnStopHoveringObject(ERayOrigin raycastOrigin, GameObject unhoveredObject) : base("Event raised when the user was hovering somethinf with a VR Raycaster, and just stop hovering it") { RaycastOrigin = raycastOrigin; UnhoveredObject = unhoveredObject; if (unhoveredObject != null) { var selectableObject = unhoveredObject.GetComponent <UnityEngine.UI.Selectable>(); if (selectableObject != null) { selectableObject.OnDeselect(null); } } HoveringVariablesContainer.SetCurrentHoveredObjects(raycastOrigin, null); FireEvent(this); }
public static void SetCurrentHoveredObjects(ERayOrigin rayOrigin, GameObject currentHit) { switch (rayOrigin) { case ERayOrigin.RIGHT_HAND: _currentRightHoveredObject = currentHit; break; case ERayOrigin.LEFT_HAND: _currentLeftHoveredObject = currentHit; break; case ERayOrigin.CAMERA: _currentGazeHoveredObject = currentHit; break; default: throw new System.Exception(); } }