} //END GetIntersectionPosition //-------------------------------------------------------------// private void UpdateReticle( GameObject previousGazedObject ) //-------------------------------------------------------------// { if( gazePointer == null ) { return; } Camera camera = pointerData.enterEventCamera; // Get the camera GameObject gazeObject = GetCurrentGameObject(); // Get the gaze target Vector3 intersectionPosition = GetIntersectionPosition(); bool isInteractive = ( pointerData.pointerPress != null || ExecuteEvents.GetEventHandler<IPointerClickHandler>( gazeObject ) != null ) && GazeCollider.ShouldGazeCursorGrow( gazeObject ); if( gazeObject == previousGazedObject ) { if( gazeObject != null ) { gazePointer.OnGazeStay( camera, gazeObject, intersectionPosition, isInteractive ); } } else { if( previousGazedObject != null ) { gazePointer.OnGazeExit( camera, previousGazedObject ); } if( gazeObject != null ) { gazePointer.OnGazeStart( camera, gazeObject, intersectionPosition, isInteractive ); } } } //END GazePointer
} //END SetCenterOfScreen //---------------------------------// //Runs every frame public override void Process() //---------------------------------// { //Set the center of the screen, changes when VRMode changes SetCenterOfScreen(); // Save the previous Game Object GameObject gazeObjectPrevious = GetCurrentGameObject(); // Cast the ray from gaze CastRayFromGaze(); //Show the raycast in editor (for debugging purposes) ShowDebugRay(); // Check if there is a gameObject at the gaze point GameObject gameObjectAtGaze = pointerData.pointerCurrentRaycast.gameObject; //If there is a gameobject at the gaze position and if the object is in the correct layer and has the correct tag, then perform GUI logic //Also check if the object has a GazeCollider script attached, if it does, check if ShouldGazeCursorFill() returns true if( gameObjectAtGaze != null && ( gameObjectAtGaze.GetComponent<XRInteractiveUI>() != null || ( IsInLayerMask( gameObjectAtGaze.layer, CollideWithLayers ) && HasTag( gameObjectAtGaze, RequiredTag ) ) ) && GazeCollider.ShouldGazeCursorFill( gameObjectAtGaze ) ) { //Debug.Log( "Found Object : Name = " + gameObjectAtGaze.name ); UpdateCurrentObject(); UpdateReticle( gazeObjectPrevious ); } else { //Debug.Log( "No Acceptable Object... gameObjectAtGaze != null = " + ( gameObjectAtGaze != null ) ); //if( gameObjectAtGaze != null ) { Debug.Log( "No Acceptable Object... IsInLayerMask = " + IsInLayerMask( gameObjectAtGaze.layer, CollideWithLayers ) ); } //if( gameObjectAtGaze != null ) { Debug.Log( "No Acceptable Object... HasTag = " + HasTag( gameObjectAtGaze, RequiredTag ) ); } HandlePointerExitAndEnter( pointerData, null ); pointerData = new PointerEventData( eventSystem ); UpdateReticle( gazeObjectPrevious ); } //Is the trigger button being pressed Down on this frame? bool isTriggered = Input.GetMouseButtonDown( 0 ); //Was the 'Click' button NOT being held down previously? bool handlePendingClickRequired = !Input.GetMouseButton( 0 ); //If this is NOT the first frame of holding down the button, then process any Drag input that might be necessary if( !Input.GetMouseButtonDown( 0 ) && Input.GetMouseButton( 0 ) ) { HandleDrag(); } else if( Time.unscaledTime - pointerData.clickTime < clickTime ) { // Delay new events until clickTime has passed. } else if( !pointerData.eligibleForClick && isTriggered ) { // New trigger action. HandleTrigger(); } else if( handlePendingClickRequired ) { // Check if there is a pending click to handle. HandlePendingClick(); } } //END Process