Exemplo n.º 1
0
    public override void TearDown()
    {
        EnhancedTouchSupport.Disable();

        // Make sure cleanup really did clean up.
        Assert.That(Touch.s_Touchscreens.length, Is.EqualTo(0));
        Assert.That(Touch.s_PlayerState, Is.EqualTo(default(Touch.FingerAndTouchState)));
        #if UNITY_EDITOR
        Assert.That(Touch.s_EditorState, Is.EqualTo(default(Touch.FingerAndTouchState)));
        #endif

        // Some state is kept alive in-between Disable/Enable. Manually clean it out.
        Touch.s_OnFingerDown = new InlinedArray <Action <Finger> >();
        Touch.s_OnFingerUp   = new InlinedArray <Action <Finger> >();
        Touch.s_OnFingerMove = new InlinedArray <Action <Finger> >();

        TouchSimulation.Destroy();
        TouchSimulation.s_Instance   = m_OldTouchSimulationInstance;
        m_OldTouchSimulationInstance = null;

        base.TearDown();
    }
Exemplo n.º 2
0
    public void EnhancedTouch_CanEnableAndDisableTouchSimulation()
    {
        Assert.That(InputSystem.devices, Has.None.TypeOf <Touchscreen>());

        TouchSimulation.Enable();

        Assert.That(InputSystem.devices, Has.Exactly(1).TypeOf <Touchscreen>());
        Assert.That(TouchSimulation.instance, Is.Not.Null);
        Assert.That(TouchSimulation.instance.simulatedTouchscreen, Is.Not.Null);
        Assert.That(TouchSimulation.instance.simulatedTouchscreen, Is.SameAs(Touchscreen.current));

        TouchSimulation.Disable();

        Assert.That(InputSystem.devices, Has.None.TypeOf <Touchscreen>());

        // Make sure we can re-enable it.
        TouchSimulation.Enable();

        Assert.That(InputSystem.devices, Has.Exactly(1).TypeOf <Touchscreen>());

        TouchSimulation.Destroy();

        Assert.That(TouchSimulation.instance, Is.Null);
    }