1616using Wave . OpenXR ;
1717using Wave . XR . Settings ;
1818using System . Text ;
19+ using System . Diagnostics ;
1920#if UNITY_EDITOR
2021using Wave . Essence . Editor ;
2122#endif
@@ -435,6 +436,7 @@ public void RestartEyeTracking(EyeTrackingResultDelegate callback)
435436 private Vector2 m_RightEyePupilPositionInSensorArea = Vector2 . zero ;
436437
437438 private bool hasEyeTrackingData = false ;
439+ private long m_Timestamp = 0 ;
438440 private void GetEyeTrackingData ( )
439441 {
440442 if ( UseXRData ( ) )
@@ -443,6 +445,7 @@ private void GetEyeTrackingData()
443445 hasEyeTrackingData = InputDeviceEye . IsEyeTrackingTracked ( ) ;
444446 if ( hasEyeTrackingData )
445447 {
448+ m_Timestamp = InputDeviceEye . GetEyeTrackingTimestamp ( ) ;
446449 m_CombinedEyeOriginValid = InputDeviceEye . GetCombinedEyeOrigin ( out m_CombinedEyeOrigin ) ;
447450 m_CombinedEyeDirectionValid = InputDeviceEye . GetCombinedEyeDirection ( out m_CombinedEyeDirection ) ;
448451
@@ -467,6 +470,8 @@ private void GetEyeTrackingData()
467470 hasEyeTrackingData = Interop . WVR_GetEyeTracking ( ref m_EyeData , ( WVR_CoordinateSystem ) m_LocationSpace ) == WVR_Result . WVR_Success ? true : false ;
468471 if ( hasEyeTrackingData )
469472 {
473+ m_Timestamp = m_EyeData . timestamp ;
474+
470475 /// Combined eye data.
471476 m_CombinedEyeOriginValid =
472477 ( ( m_EyeData . combined . eyeTrackingValidBitMask & ( ulong ) WVR_EyeTrackingStatus . WVR_GazeOriginValid ) != 0 ) ;
@@ -628,6 +633,8 @@ public bool IsEyeTrackingAvailable()
628633 /// <summary> Checks if the eye tracking data is provided. </summary>
629634 public bool HasEyeTrackingData ( ) { return hasEyeTrackingData ; }
630635
636+ public long GetEyeTrackingTimestamp ( ) { return m_Timestamp ; }
637+
631638 /// <summary> Retrieves the origin location of specified eye. </summary>
632639 public bool GetEyeOrigin ( EyeType eye , out Vector3 origin )
633640 {
@@ -639,6 +646,11 @@ public bool GetEyeOrigin(EyeType eye, out Vector3 origin)
639646
640647 return false ;
641648 }
649+ public bool GetEyeOrigin ( EyeType eye , out Vector3 origin , out long timestamp )
650+ {
651+ timestamp = m_Timestamp ;
652+ return GetEyeOrigin ( eye , out origin ) ;
653+ }
642654 public bool GetEyeDirectionNormalized ( EyeType eye , out Vector3 direction )
643655 {
644656 direction = Vector3 . zero ;
@@ -649,6 +661,11 @@ public bool GetEyeDirectionNormalized(EyeType eye, out Vector3 direction)
649661
650662 return false ;
651663 }
664+ public bool GetEyeDirectionNormalized ( EyeType eye , out Vector3 direction , out long timestamp )
665+ {
666+ timestamp = m_Timestamp ;
667+ return GetEyeDirectionNormalized ( eye , out direction ) ;
668+ }
652669
653670 // ------------------------- Combined Eye -------------------------
654671 /// <summary> Retrieves the origin location of combined eye. </summary>
@@ -662,6 +679,11 @@ public bool GetCombinedEyeOrigin(out Vector3 origin)
662679 origin = m_CombinedEyeOrigin ;
663680 return m_CombinedEyeOriginValid ;
664681 }
682+ public bool GetCombinedEyeOrigin ( out Vector3 origin , out long timestamp )
683+ {
684+ timestamp = m_Timestamp ;
685+ return GetCombinedEyeOrigin ( out origin ) ;
686+ }
665687 /// <summary> Retrieves the looking direction (z-normalized) of combined eye. </summary>
666688 public bool GetCombindedEyeDirectionNormalized ( out Vector3 direction )
667689 {
@@ -673,6 +695,11 @@ public bool GetCombindedEyeDirectionNormalized(out Vector3 direction)
673695 direction = m_CombinedEyeDirection ;
674696 return m_CombinedEyeDirectionValid ;
675697 }
698+ public bool GetCombindedEyeDirectionNormalized ( out Vector3 direction , out long timestamp )
699+ {
700+ timestamp = m_Timestamp ;
701+ return GetCombindedEyeDirectionNormalized ( out direction ) ;
702+ }
676703
677704 // ------------------------- Left Eye -------------------------
678705 /// <summary> Retrieves the origin location of left eye. </summary>
@@ -686,6 +713,11 @@ public bool GetLeftEyeOrigin(out Vector3 origin)
686713 origin = m_LeftEyeOrigin ;
687714 return m_LeftEyeOriginValid ;
688715 }
716+ public bool GetLeftEyeOrigin ( out Vector3 origin , out long timestamp )
717+ {
718+ timestamp = m_Timestamp ;
719+ return GetLeftEyeOrigin ( out origin ) ;
720+ }
689721 /// <summary> Retrieves the looking direction (z-normalized) of left eye. </summary>
690722 public bool GetLeftEyeDirectionNormalized ( out Vector3 direction )
691723 {
@@ -697,6 +729,11 @@ public bool GetLeftEyeDirectionNormalized(out Vector3 direction)
697729 direction = m_LeftEyeDirection ;
698730 return m_LeftEyeDirectionValid ;
699731 }
732+ public bool GetLeftEyeDirectionNormalized ( out Vector3 direction , out long timestamp )
733+ {
734+ timestamp = m_Timestamp ;
735+ return GetLeftEyeDirectionNormalized ( out direction ) ;
736+ }
700737 /// <summary> Retrieves the value representing how open the left eye is. </summary>
701738 public bool GetLeftEyeOpenness ( out float openness )
702739 {
@@ -708,6 +745,11 @@ public bool GetLeftEyeOpenness(out float openness)
708745 openness = m_LeftEyeOpenness ;
709746 return m_LeftEyeOpennessValid ;
710747 }
748+ public bool GetLeftEyeOpenness ( out float openness , out long timestamp )
749+ {
750+ timestamp = m_Timestamp ;
751+ return GetLeftEyeOpenness ( out openness ) ;
752+ }
711753 /// <summary> Retrieves the diameter of left eye pupil in millimeters. </summary>
712754 public bool GetLeftEyePupilDiameter ( out float diameter )
713755 {
@@ -719,6 +761,11 @@ public bool GetLeftEyePupilDiameter(out float diameter)
719761 diameter = m_LeftEyePupilDiameter ;
720762 return m_LeftEyePupilDiameterValid ;
721763 }
764+ public bool GetLeftEyePupilDiameter ( out float diameter , out long timestamp )
765+ {
766+ timestamp = m_Timestamp ;
767+ return GetLeftEyePupilDiameter ( out diameter ) ;
768+ }
722769 /// <summary> Retrieves the normalized position of left eye pupil in [0,1]. </summary>
723770 public bool GetLeftEyePupilPositionInSensorArea ( out Vector2 area )
724771 {
@@ -730,6 +777,11 @@ public bool GetLeftEyePupilPositionInSensorArea(out Vector2 area)
730777 area = m_LeftEyePupilPositionInSensorArea ;
731778 return m_LeftEyePupilPositionInSensorAreaValid ;
732779 }
780+ public bool GetLeftEyePupilPositionInSensorArea ( out Vector2 area , out long timestamp )
781+ {
782+ timestamp = m_Timestamp ;
783+ return GetLeftEyePupilPositionInSensorArea ( out area ) ;
784+ }
733785
734786 // ------------------------- Right Eye -------------------------
735787 /// <summary> Retrieves the origin location of right eye. </summary>
@@ -743,6 +795,11 @@ public bool GetRightEyeOrigin(out Vector3 origin)
743795 origin = m_RightEyeOrigin ;
744796 return m_RightEyeOriginValid ;
745797 }
798+ public bool GetRightEyeOrigin ( out Vector3 origin , out long timestamp )
799+ {
800+ timestamp = m_Timestamp ;
801+ return GetRightEyeOrigin ( out origin ) ;
802+ }
746803 /// <summary> Retrieves the looking direction (z-normalized) of right eye. </summary>
747804 public bool GetRightEyeDirectionNormalized ( out Vector3 direction )
748805 {
@@ -754,6 +811,11 @@ public bool GetRightEyeDirectionNormalized(out Vector3 direction)
754811 direction = m_RightEyeDirection ;
755812 return m_RightEyeDirectionValid ;
756813 }
814+ public bool GetRightEyeDirectionNormalized ( out Vector3 direction , out long timestamp )
815+ {
816+ timestamp = m_Timestamp ;
817+ return GetRightEyeDirectionNormalized ( out direction ) ;
818+ }
757819 /// <summary> Retrieves the value representing how open the right eye is. </summary>
758820 public bool GetRightEyeOpenness ( out float openness )
759821 {
@@ -765,6 +827,11 @@ public bool GetRightEyeOpenness(out float openness)
765827 openness = m_RightEyeOpenness ;
766828 return m_RightEyeOpennessValid ;
767829 }
830+ public bool GetRightEyeOpenness ( out float openness , out long timestamp )
831+ {
832+ timestamp = m_Timestamp ;
833+ return GetRightEyeOpenness ( out openness ) ;
834+ }
768835 /// <summary> Retrieves the diameter of right eye pupil in millimeters. </summary>
769836 public bool GetRightEyePupilDiameter ( out float diameter )
770837 {
@@ -776,6 +843,11 @@ public bool GetRightEyePupilDiameter(out float diameter)
776843 diameter = m_RightEyePupilDiameter ;
777844 return m_RightEyePupilDiameterValid ;
778845 }
846+ public bool GetRightEyePupilDiameter ( out float diameter , out long timestamp )
847+ {
848+ timestamp = m_Timestamp ;
849+ return GetRightEyePupilDiameter ( out diameter ) ;
850+ }
779851 /// <summary> Retrieves the normalized position of right eye pupil in [0,1]. </summary>
780852 public bool GetRightEyePupilPositionInSensorArea ( out Vector2 area )
781853 {
@@ -787,6 +859,11 @@ public bool GetRightEyePupilPositionInSensorArea(out Vector2 area)
787859 area = m_RightEyePupilPositionInSensorArea ;
788860 return m_RightEyePupilPositionInSensorAreaValid ;
789861 }
862+ public bool GetRightEyePupilPositionInSensorArea ( out Vector2 area , out long timestamp )
863+ {
864+ timestamp = m_Timestamp ;
865+ return GetRightEyePupilPositionInSensorArea ( out area ) ;
866+ }
790867 #endregion
791868 }
792869
0 commit comments