3131using UnityEditor . SceneManagement ;
3232#endif
3333
34- #if UNITY_2021_2_OR_NEWER
3534using UnityEngine . UIElements ;
36- #endif
3735
3836#pragma warning disable CS0649
3937////TODO: app focus handling
@@ -399,13 +397,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
399397 }
400398 yield return null ;
401399
402- const int kHaveMovementEvents =
403- #if UNITY_2021_2_OR_NEWER
404- 1
405- #else
406- 0
407- #endif
408- ;
400+ const int kHaveMovementEvents = 1 ;
409401
410402 Assert . That ( scene . leftChildReceiver . events , Has . Count . EqualTo ( ( isTouch ? 3 : 1 ) + kHaveMovementEvents ) ) ;
411403 Assert . That ( scene . parentReceiver . events , Has . Count . EqualTo ( 1 + kHaveMovementEvents ) ) ;
@@ -486,7 +478,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
486478 // Touch has no ability to point without pressing so pointer enter event is followed
487479 // right by pointer down event.
488480
489- #if UNITY_2021_2_OR_NEWER
490481 // PointerMove.
491482 Assert . That ( scene . leftChildReceiver . events [ 0 + kHaveMovementEvents ] . type , Is . EqualTo ( EventType . PointerMove ) ) ;
492483 Assert . That ( scene . leftChildReceiver . events [ 0 + kHaveMovementEvents ] . pointerData . button , Is . EqualTo ( PointerEventData . InputButton . Left ) ) ;
@@ -514,7 +505,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
514505 Assert . That ( scene . leftChildReceiver . events [ 0 + kHaveMovementEvents ] . pointerData . pointerPressRaycast . gameObject , Is . Null ) ;
515506 Assert . That ( scene . leftChildReceiver . events [ 0 + kHaveMovementEvents ] . pointerData . pointerPressRaycast . screenPosition ,
516507 Is . EqualTo ( default ( Vector2 ) ) . Using ( Vector2EqualityComparer . Instance ) ) ;
517- #endif
518508
519509 // PointerDown.
520510 Assert . That ( scene . leftChildReceiver . events [ 1 + kHaveMovementEvents ] . type , Is . EqualTo ( EventType . PointerDown ) ) ;
@@ -741,7 +731,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
741731 AllEvents ( "pointerCurrentRaycast.screenPosition" , secondScreenPosition ) ,
742732
743733 // PointerMove.
744- #if UNITY_2021_2_OR_NEWER
745734 OneEvent ( "type" , EventType . PointerMove ) ,
746735 OneEvent ( "dragging" , false ) ,
747736 // Again, pointer movement is processed exclusively "from" the left button.
@@ -755,7 +744,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
755744 OneEvent ( "lastPress" , clickButton == PointerEventData . InputButton . Left ? null : scene . leftGameObject ) ,
756745 OneEvent ( "pointerPressRaycast.gameObject" , clickButton == PointerEventData . InputButton . Left ? scene . leftGameObject : null ) ,
757746 OneEvent ( "pointerPressRaycast.screenPosition" , clickButton == PointerEventData . InputButton . Left ? firstScreenPosition : Vector2 . zero ) ,
758- #endif
759747
760748 // BeginDrag.
761749 OneEvent ( "type" , EventType . BeginDrag ) ,
@@ -788,12 +776,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
788776 ) ;
789777
790778 Assert . That ( scene . rightChildReceiver . events , Is . Empty ) ;
791- Assert . That ( scene . parentReceiver . events ,
792- EventSequence (
793- #if UNITY_2021_2_OR_NEWER
794- OneEvent ( "type" , EventType . PointerMove )
795- #endif
796- )
779+ Assert . That ( scene . parentReceiver . events , EventSequence ( OneEvent ( "type" , EventType . PointerMove ) )
797780 ) ;
798781
799782 scene . leftChildReceiver . events . Clear ( ) ;
@@ -819,12 +802,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
819802 Assert . That ( scene . eventSystem . IsPointerOverGameObject ( pointerId ) , Is . True ) ;
820803 // Should not have seen pointer enter/exit on parent (we only moved from one of its
821804 // children to another) but *should* have seen a move event.
822- Assert . That ( scene . parentReceiver . events ,
823- EventSequence (
824- #if UNITY_2021_2_OR_NEWER
825- OneEvent ( "type" , EventType . PointerMove )
826- #endif
827- )
805+ Assert . That ( scene . parentReceiver . events , EventSequence ( OneEvent ( "type" , EventType . PointerMove ) )
828806 ) ;
829807
830808 if ( isTracked )
@@ -852,7 +830,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
852830 // press positions on the moves will be zero.
853831
854832 // PointerMove.
855- #if UNITY_2021_2_OR_NEWER
856833 OneEvent ( "type" , EventType . PointerMove ) ,
857834 OneEvent ( "button" , PointerEventData . InputButton . Left ) ,
858835 OneEvent ( "pointerEnter" , scene . leftGameObject ) ,
@@ -867,7 +844,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
867844 OneEvent ( "dragging" , clickButton == PointerEventData . InputButton . Left ? true : false ) ,
868845 OneEvent ( "pointerPressRaycast.gameObject" , clickButton == PointerEventData . InputButton . Left ? scene . leftGameObject : null ) ,
869846 OneEvent ( "pointerPressRaycast.screenPosition" , clickButton == PointerEventData . InputButton . Left ? firstScreenPosition : Vector2 . zero ) ,
870- #endif
871847
872848 // PointerExit.
873849 OneEvent ( "type" , EventType . PointerExit ) ,
@@ -927,10 +903,8 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
927903 AllEvents ( "pointerPressRaycast.gameObject" , clickButton == PointerEventData . InputButton . Left ? scene . leftGameObject : null ) ,
928904 AllEvents ( "pointerPressRaycast.screenPosition" , clickButton == PointerEventData . InputButton . Left ? firstScreenPosition : Vector2 . zero ) ,
929905
930- OneEvent ( "type" , EventType . PointerEnter )
931- #if UNITY_2021_2_OR_NEWER
932- , OneEvent ( "type" , EventType . PointerMove )
933- #endif
906+ OneEvent ( "type" , EventType . PointerEnter ) ,
907+ OneEvent ( "type" , EventType . PointerMove )
934908 )
935909 ) ;
936910
@@ -1892,15 +1866,13 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
18921866 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . pointerType == UIPointerType . Touch ) . And
18931867 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . position == secondPosition ) ) ;
18941868
1895- #if UNITY_2021_2_OR_NEWER
18961869 Assert . That ( scene . rightChildReceiver . events ,
18971870 Has . Exactly ( 1 ) . With . Property ( "type" ) . EqualTo ( EventType . PointerMove ) . And
18981871 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . device == touchScreen ) . And
18991872 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . touchId == 2 ) . And
19001873 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . pointerId == pointerIdTouch2 ) . And
19011874 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . pointerType == UIPointerType . Touch ) . And
19021875 . Matches ( ( UICallbackReceiver . Event e ) => e . pointerData . position == secondPosition ) ) ;
1903- #endif
19041876
19051877 // Pointer 3
19061878 Assert . That ( scene . rightChildReceiver . events ,
@@ -2025,12 +1997,10 @@ public IEnumerator UI_CanUseTouchSimulationWithUI()
20251997 AllEvents ( "pointerType" , UIPointerType . Touch ) ,
20261998 AllEvents ( "touchId" , 1 ) ,
20271999 AllEvents ( "position" , scene . From640x480ToScreen ( 180 , 180 ) ) ,
2028- OneEvent ( "type" , EventType . PointerEnter )
2029- #if UNITY_2021_2_OR_NEWER
2030- , OneEvent ( "type" , EventType . PointerMove )
2031- #endif
2032- , OneEvent ( "type" , EventType . PointerDown )
2033- , OneEvent ( "type" , EventType . InitializePotentialDrag )
2000+ OneEvent ( "type" , EventType . PointerEnter ) ,
2001+ OneEvent ( "type" , EventType . PointerMove ) ,
2002+ OneEvent ( "type" , EventType . PointerDown ) ,
2003+ OneEvent ( "type" , EventType . InitializePotentialDrag )
20342004 )
20352005 ) ;
20362006
@@ -2149,10 +2119,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
21492119 AllEvents ( "pointerId" , trackedDevice1 . deviceId ) ,
21502120 AllEvents ( "device" , trackedDevice1 ) ,
21512121 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . leftGameObject ) ) ,
2152- OneEvent ( "type" , EventType . PointerEnter )
2153- #if UNITY_2021_2_OR_NEWER
2154- , OneEvent ( "type" , EventType . PointerMove )
2155- #endif
2122+ OneEvent ( "type" , EventType . PointerEnter ) ,
2123+ OneEvent ( "type" , EventType . PointerMove )
21562124 )
21572125 ) ;
21582126 Assert . That ( scene . rightChildReceiver . events , Is . Empty ) ;
@@ -2169,10 +2137,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
21692137 AllEvents ( "pointerId" , trackedDevice2 . deviceId ) ,
21702138 AllEvents ( "device" , trackedDevice2 ) ,
21712139 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . leftGameObject , Vector3 . left ) ) ,
2172- OneEvent ( "type" , EventType . PointerEnter )
2173- #if UNITY_2021_2_OR_NEWER
2174- , OneEvent ( "type" , EventType . PointerMove )
2175- #endif
2140+ OneEvent ( "type" , EventType . PointerEnter ) ,
2141+ OneEvent ( "type" , EventType . PointerMove )
21762142 )
21772143 ) ;
21782144 Assert . That ( scene . rightChildReceiver . events , Is . Empty ) ;
@@ -2230,9 +2196,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
22302196 AllEvents ( "pointerId" , trackedDevice1 . deviceId ) ,
22312197 AllEvents ( "device" , trackedDevice1 ) ,
22322198 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . rightGameObject ) ) ,
2233- #if UNITY_2021_2_OR_NEWER
22342199 OneEvent ( "type" , EventType . PointerMove ) ,
2235- #endif
22362200 OneEvent ( "type" , EventType . PointerExit )
22372201 )
22382202 ) ;
@@ -2242,10 +2206,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
22422206 AllEvents ( "pointerId" , trackedDevice1 . deviceId ) ,
22432207 AllEvents ( "device" , trackedDevice1 ) ,
22442208 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . rightGameObject ) ) ,
2245- OneEvent ( "type" , EventType . PointerEnter )
2246- #if UNITY_2021_2_OR_NEWER
2247- , OneEvent ( "type" , EventType . PointerMove )
2248- #endif
2209+ OneEvent ( "type" , EventType . PointerEnter ) ,
2210+ OneEvent ( "type" , EventType . PointerMove )
22492211 )
22502212 ) ;
22512213
@@ -2262,9 +2224,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
22622224 AllEvents ( "pointerId" , trackedDevice2 . deviceId ) ,
22632225 AllEvents ( "device" , trackedDevice2 ) ,
22642226 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . rightGameObject , Vector3 . right ) ) ,
2265- #if UNITY_2021_2_OR_NEWER
22662227 OneEvent ( "type" , EventType . PointerMove ) ,
2267- #endif
22682228 OneEvent ( "type" , EventType . PointerExit )
22692229 )
22702230 ) ;
@@ -2275,9 +2235,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices()
22752235 AllEvents ( "device" , trackedDevice2 ) ,
22762236 AllEvents ( "trackedDeviceOrientation" , scene . GetLookAtQuaternion ( Vector3 . zero , scene . rightGameObject , Vector3 . right ) ) ,
22772237 OneEvent ( "type" , EventType . PointerEnter )
2278- #if UNITY_2021_2_OR_NEWER
22792238 , OneEvent ( "type" , EventType . PointerMove )
2280- #endif
22812239 )
22822240 ) ;
22832241 }
@@ -2601,12 +2559,7 @@ public IEnumerator UI_CanGetRaycastResultMatchingEvent()
26012559 var raycastResult = scene . uiModule . GetLastRaycastResult ( trackedDevice . deviceId ) ;
26022560 Assert . That ( raycastResult . isValid , Is . True ) ;
26032561
2604- //2021.2 added an additional move event.
2605- #if UNITY_2021_2_OR_NEWER
26062562 Assert . That ( scene . leftChildReceiver . events , Has . Count . EqualTo ( 2 ) ) ;
2607- #else
2608- Assert . That ( scene . leftChildReceiver . events , Has . Count . EqualTo ( 1 ) ) ;
2609- #endif
26102563 Assert . That ( scene . leftChildReceiver . events [ 0 ] . pointerData , Is . Not . Null ) ;
26112564
26122565 var eventRaycastResult = scene . leftChildReceiver . events [ 0 ] . pointerData . pointerCurrentRaycast ;
@@ -4041,9 +3994,7 @@ public IEnumerator UI_CanOperateUIToolkitInterface_UsingInputSystemUIInputModule
40413994 ////FIXME: as of a time of writing, this line is broken on trunk due to the bug in UITK
40423995 // The bug is https://fogbugz.unity3d.com/f/cases/1323488/
40433996 // just adding a define as a safeguard measure to reenable it when trunk goes to next version cycle
4044- #if UNITY_2021_3_OR_NEWER
40453997 Assert . That ( scrollView . verticalScroller . value , Is . GreaterThan ( 0 ) ) ;
4046- #endif
40473998
40483999 // Try a button press with the gamepad.
40494000 // NOTE: The current version of UITK does not focus the button automatically. Fix for that is in the pipe.
@@ -4171,9 +4122,7 @@ public IEnumerator UI_WhenAppLosesAndRegainsFocus_WhileUIButtonIsPressed_UIButto
41714122 Assert . That ( scene . leftChildReceiver . events ,
41724123 EventSequence (
41734124 OneEvent ( "type" , EventType . PointerEnter ) ,
4174- #if UNITY_2021_2_OR_NEWER
41754125 OneEvent ( "type" , EventType . PointerMove ) ,
4176- #endif
41774126 OneEvent ( "type" , EventType . PointerDown ) ,
41784127 OneEvent ( "type" , EventType . InitializePotentialDrag )
41794128 )
@@ -4636,9 +4585,7 @@ private enum EventType
46364585 PointerUp ,
46374586 PointerEnter ,
46384587 PointerExit ,
4639- #if UNITY_2021_2_OR_NEWER
46404588 PointerMove ,
4641- #endif
46424589 Select ,
46434590 Deselect ,
46444591 InitializePotentialDrag ,
@@ -4653,11 +4600,8 @@ private enum EventType
46534600 }
46544601
46554602 private class UICallbackReceiver : MonoBehaviour , IPointerClickHandler , IPointerDownHandler , IPointerEnterHandler ,
4656- #if UNITY_2021_2_OR_NEWER
4657- IPointerMoveHandler ,
4658- #endif
4659- IPointerExitHandler , IPointerUpHandler , IMoveHandler , ISelectHandler , IDeselectHandler , IInitializePotentialDragHandler ,
4660- IBeginDragHandler , IDragHandler , IEndDragHandler , IDropHandler , ISubmitHandler , ICancelHandler , IScrollHandler
4603+ IPointerMoveHandler , IPointerExitHandler , IPointerUpHandler , IMoveHandler , ISelectHandler , IDeselectHandler ,
4604+ IInitializePotentialDragHandler , IBeginDragHandler , IDragHandler , IEndDragHandler , IDropHandler , ISubmitHandler , ICancelHandler , IScrollHandler
46614605 {
46624606 public struct Event
46634607 {
@@ -4709,14 +4653,11 @@ public void OnPointerUp(PointerEventData eventData)
47094653 events . Add ( new Event ( EventType . PointerUp , ClonePointerEventData ( eventData ) ) ) ;
47104654 }
47114655
4712- #if UNITY_2021_2_OR_NEWER
47134656 public void OnPointerMove ( PointerEventData eventData )
47144657 {
47154658 events . Add ( new Event ( EventType . PointerMove , ClonePointerEventData ( eventData ) ) ) ;
47164659 }
47174660
4718- #endif
4719-
47204661 public void OnMove ( AxisEventData eventData )
47214662 {
47224663 events . Add ( new Event ( EventType . Move , CloneAxisEventData ( eventData ) ) ) ;
@@ -4824,15 +4765,13 @@ private static ExtendedPointerEventData ClonePointerEventData(PointerEventData e
48244765 pointerType = extendedEventData . pointerType ,
48254766 trackedDeviceOrientation = extendedEventData . trackedDeviceOrientation ,
48264767 trackedDevicePosition = extendedEventData . trackedDevicePosition ,
4827- #if UNITY_2021_1_OR_NEWER
48284768 pressure = eventData . pressure ,
48294769 tangentialPressure = eventData . tangentialPressure ,
48304770 altitudeAngle = eventData . altitudeAngle ,
48314771 azimuthAngle = eventData . azimuthAngle ,
48324772 twist = eventData . twist ,
48334773 radius = eventData . radius ,
48344774 radiusVariance = eventData . radiusVariance ,
4835- #endif
48364775#if UNITY_2022_3_OR_NEWER
48374776 displayIndex = eventData . displayIndex ,
48384777#endif
0 commit comments