@@ -291,6 +291,92 @@ public IEnumerator TouchEvents_CanReceiveOnMouseDown()
291291 Assert . That ( gameObject . transform . position , Is . EqualTo ( new Vector3 ( 0 , 0 , 1 ) ) , "No MouseDown event received." ) ;
292292 }
293293
294+ [ UnityTest ]
295+ [ Category ( "MouseEvents" ) ]
296+ public IEnumerator TouchEvents_CanReceiveOnMouseUp ( )
297+ {
298+ var touch = InputSystem . AddDevice < Touchscreen > ( ) ;
299+
300+ var gameObject = SetUpScene ( ) ;
301+ gameObject . AddComponent < OnMouseEventsTest > ( ) ;
302+ var vec = Camera . main . WorldToScreenPoint ( gameObject . transform . position ) ;
303+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Began ) ;
304+ yield return null ;
305+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Ended ) ;
306+ yield return null ;
307+ Assert . That ( gameObject . transform . position , Is . EqualTo ( new Vector3 ( 0 , 0 , 2 ) ) , "No MouseUp event received." ) ;
308+ }
309+
310+ [ UnityTest ]
311+ [ Category ( "MouseEvents" ) ]
312+ public IEnumerator TouchEvents_CanReceiveOnMouseUpAsButton ( )
313+ {
314+ var touch = InputSystem . AddDevice < Touchscreen > ( ) ;
315+
316+ var gameObject = SetUpScene ( ) ;
317+ gameObject . AddComponent < OnMousEventTestTwo > ( ) ;
318+ var vec = Camera . main . WorldToScreenPoint ( gameObject . transform . position ) ;
319+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Began ) ;
320+ yield return null ;
321+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Ended ) ;
322+ yield return null ;
323+ Assert . That ( gameObject . transform . position , Is . EqualTo ( new Vector3 ( 0 , 0 , 1 ) ) , "No MouseUpAsButton event received." ) ;
324+ }
325+
326+ [ UnityTest ]
327+ [ Category ( "MouseEvents" ) ]
328+ public IEnumerator TouchEvents_CanReceiveOnMouseDrag ( )
329+ {
330+ var touch = InputSystem . AddDevice < Touchscreen > ( ) ;
331+
332+ var gameObject = SetUpScene ( ) ;
333+ gameObject . AddComponent < OnMouseEventsTest > ( ) ;
334+ var vec = Camera . main . WorldToScreenPoint ( gameObject . transform . position ) ;
335+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Ended ) ;
336+ yield return null ;
337+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Began ) ;
338+ yield return null ;
339+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . Moved ) ;
340+ yield return null ;
341+ SetTouch ( touch , new Vector2 ( vec . x + 1f , vec . y ) , TouchPhase . Moved ) ;
342+ yield return null ;
343+ Assert . That ( gameObject . transform . position , Is . EqualTo ( new Vector3 ( 0 , 0 , 3 ) ) , "No MouseDrag event received." ) ;
344+ }
345+
346+ [ UnityTest ]
347+ [ Category ( "MouseEvents" ) ]
348+ public IEnumerator TouchEvents_CanReceiveOnMouseEnterAndMouseExit ( )
349+ {
350+ var touch = InputSystem . AddDevice < Touchscreen > ( ) ;
351+
352+ var gameObject = SetUpScene ( ) ;
353+ gameObject . AddComponent < OnMouseEventsTest > ( ) ;
354+ var vec = Camera . main . WorldToScreenPoint ( gameObject . transform . position ) ;
355+ SetTouch ( touch , new Vector2 ( 0 , 0 ) , TouchPhase . Ended ) ;
356+ yield return null ;
357+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . None ) ;
358+ yield return null ;
359+ Assert . That ( gameObject . GetComponent < Renderer > ( ) . material . color , Is . EqualTo ( Color . green ) , "No MouseEnter event received." ) ;
360+
361+ SetTouch ( touch , new Vector2 ( 0 , 0 ) , TouchPhase . None ) ;
362+ yield return null ;
363+ Assert . That ( gameObject . GetComponent < Renderer > ( ) . material . color , Is . EqualTo ( Color . red ) , "No MouseExit event received." ) ;
364+ }
365+
366+ [ UnityTest ]
367+ [ Category ( "MouseEvents" ) ]
368+ public IEnumerator TouchEvents_CanReceiveOnMouseOver ( )
369+ {
370+ var touch = InputSystem . AddDevice < Touchscreen > ( ) ;
371+
372+ var gameObject = SetUpScene ( ) ;
373+ gameObject . AddComponent < OnMousEventTestTwo > ( ) ;
374+ var vec = Camera . main . WorldToScreenPoint ( gameObject . transform . position ) ;
375+ SetTouch ( touch , new Vector2 ( vec . x , vec . y ) , TouchPhase . None ) ;
376+ yield return null ;
377+ Assert . That ( gameObject . GetComponent < Renderer > ( ) . material . color , Is . EqualTo ( Color . blue ) , "No MouseOver event received." ) ;
378+ }
379+
294380 private long m_eventSize = UnsafeUtility . SizeOf < StateEvent > ( ) + ( uint ) UnsafeUtility . SizeOf < TouchState > ( ) - StateEvent . kStateDataSizeToSubtract ;
295381
296382 // we need to use the NativeInputRuntime to queue the events in order to get the input events in native
0 commit comments