public void EnhancedTouch_SupportsEditorUpdates(InputSettings.UpdateMode updateMode) { InputSystem.settings.timesliceEvents = false; InputEditorUserSettings.lockInputToGameView = false; InputSystem.settings.updateMode = updateMode; // Run one player update with data. BeginTouch(1, new Vector2(0.123f, 0.234f)); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); // And make sure we're not seeing the data in the editor. runtime.PlayerFocusLost(); InputSystem.Update(InputUpdateType.Editor); Assert.That(Touch.activeTouches, Is.Empty); // Feed some data into editor state. BeginTouch(2, new Vector2(0.234f, 0.345f), queueEventOnly: true); InputSystem.Update(InputUpdateType.Editor); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); Assert.That(Touch.activeTouches[0].touchId, Is.EqualTo(2)); // Switch back to player. runtime.PlayerFocusGained(); InputSystem.Update(); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); Assert.That(Touch.activeTouches[0].touchId, Is.EqualTo(1)); }
public void EditMode_RunUpdatesInEditMode_AllowsNonEditorUpdates(InputSettings.UpdateMode updateMode, InputUpdateType updateType) { #if ENABLE_XR_COMBINED_DEFINE runtime.isInPlayMode = false; InputSystem.settings.updateMode = updateMode; var counter = new InputUpdateCounter(); counter.Start(); InputSystem.Update(InputUpdateType.Editor); InputSystem.Update(updateType); Assert.That(counter.updates.Count, Is.EqualTo(1)); Assert.That(counter.updates[0], Is.EqualTo(InputUpdateType.Editor)); counter.Reset(); InputSystem.runUpdatesInEditMode = true; InputSystem.Update(InputUpdateType.Editor); InputSystem.Update(updateType); Assert.That(counter.updates.Count, Is.EqualTo(2)); Assert.That(counter.updates[0], Is.EqualTo(InputUpdateType.Editor)); Assert.That(counter.updates[1], Is.EqualTo(updateType)); counter.Reset(); InputSystem.runUpdatesInEditMode = false; runtime.isInPlayMode = true; counter.Stop(); #endif }
public void EnhancedTouch_SupportsEditorUpdates(InputSettings.UpdateMode updateMode) { // To better observe that play mode and edit mode state is indeed independent and handled // correctly, suppress resetting of the touch device when focus is lost to the player. runtime.runInBackground = true; SetCanRunInBackground(Touchscreen.current); InputEditorUserSettings.lockInputToGameView = false; InputSystem.settings.updateMode = updateMode; runtime.currentTimeForFixedUpdate += Time.fixedDeltaTime; // Run one player update with data. BeginTouch(1, new Vector2(0.123f, 0.234f)); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); // And make sure we're not seeing the data in the editor. runtime.PlayerFocusLost(); InputSystem.Update(InputUpdateType.Editor); Assert.That(Touch.activeTouches, Is.Empty); // Feed some data into editor state. BeginTouch(2, new Vector2(0.234f, 0.345f), queueEventOnly: true); InputSystem.Update(InputUpdateType.Editor); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); Assert.That(Touch.activeTouches[0].touchId, Is.EqualTo(2)); // Switch back to player. runtime.PlayerFocusGained(); InputSystem.Update(); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); Assert.That(Touch.activeTouches[0].touchId, Is.EqualTo(1)); }
public void EnhancedTouch_SupportsInputUpdateIn(InputSettings.UpdateMode updateMode, InputUpdateType updateType) { InputSystem.settings.updateMode = updateMode; runtime.currentTimeForFixedUpdate += Time.fixedDeltaTime; BeginTouch(1, new Vector2(0.123f, 0.234f), queueEventOnly: true); InputSystem.Update(updateType); Assert.That(Touch.activeTouches, Has.Count.EqualTo(1)); Assert.That(Touch.activeTouches[0].screenPosition, Is.EqualTo(new Vector2(0.123f, 0.234f)).Using(Vector2EqualityComparer.Instance)); }
private static void SetUpState() { Touch.s_GlobalState.playerState.updateMask = InputUpdateType.Dynamic | InputUpdateType.Manual | InputUpdateType.Fixed; #if UNITY_EDITOR Touch.s_GlobalState.editorState.updateMask = InputUpdateType.Editor; #endif s_UpdateMode = InputSystem.settings.updateMode; foreach (var device in InputSystem.devices) { OnDeviceChange(device, InputDeviceChange.Added); } }