public void TouchscreenAddedAndRemoved() { var plugin = new InputSystemPlugin(); plugin.OnCreate(); var touchscreen = plugin.SimulatorTouchscreen; Assert.IsTrue(touchscreen.added); plugin.OnDestroy(); Assert.IsFalse(touchscreen.added); }
public IEnumerator InputEventsArePropagated() { EnhancedTouchSupport.Enable(); var plugin = new InputSystemPlugin(); plugin.OnCreate(); yield return(null); plugin.OnTouchEvent(CreateTouch(0, new Vector2(5, 5), UnityEditor.DeviceSimulation.TouchPhase.Began)); yield return(null); var activeTouches = Touch.activeTouches; Assert.Greater(activeTouches.Count, 0); Assert.AreEqual(new Vector2(5, 5), Touch.activeTouches[0].screenPosition); Assert.AreEqual(TouchPhase.Began, Touch.activeTouches[0].phase); yield return(null); Assert.AreEqual(new Vector2(5, 5), Touch.activeTouches[0].screenPosition); Assert.AreEqual(TouchPhase.Stationary, Touch.activeTouches[0].phase); plugin.OnTouchEvent(CreateTouch(0, new Vector2(10, 10), UnityEditor.DeviceSimulation.TouchPhase.Moved)); yield return(null); Assert.AreEqual(new Vector2(10, 10), Touch.activeTouches[0].screenPosition); Assert.AreEqual(TouchPhase.Moved, Touch.activeTouches[0].phase); plugin.OnTouchEvent(CreateTouch(0, new Vector2(5, 5), UnityEditor.DeviceSimulation.TouchPhase.Ended)); yield return(null); Assert.AreEqual(new Vector2(5, 5), Touch.activeTouches[0].screenPosition); Assert.AreEqual(TouchPhase.Ended, Touch.activeTouches[0].phase); yield return(null); Assert.AreEqual(Touch.activeTouches.Count, 0); plugin.OnDestroy(); EnhancedTouchSupport.Disable(); }