示例#1
0
        public IEnumerator TestDisabledPointerCache()
        {
            TestButtonUtilities.InstantiateDefaultButton(TestButtonUtilities.DefaultButtonType.DefaultPushButton,
                                                         out Interactable interactable,
                                                         out Transform translateTargetObject);

            Vector3 targetStartPosition = translateTargetObject.localPosition;

            // Subscribe to interactable's on click so we know the click went through
            bool wasClicked = false;

            interactable.OnClick.AddListener(() => { wasClicked = true; });

            PlayModeTestUtilities.GetInputSimulationService().EnablePointerCache = false;

            var rightHand = new TestHand(Handedness.Right);

            yield return(rightHand.Show(Vector3.right));

            var rightPokePointer = PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right);

            Assert.IsNotNull(rightPokePointer);
            Assert.IsFalse(rightPokePointer.DestroyOnSourceLost);

            yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, translateTargetObject));

            Assert.IsTrue(wasClicked);
            Assert.IsTrue(rightPokePointer == null);
            Assert.IsNull(PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right));

            wasClicked = false;
            yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, translateTargetObject));

            Assert.IsTrue(wasClicked);
        }
示例#2
0
        public IEnumerator TestPointerCaching()
        {
            TestButtonUtilities.InstantiateDefaultButton(TestButtonUtilities.DefaultButtonType.DefaultPushButton,
                                                         out Interactable interactable,
                                                         out Transform translateTargetObject);

            Vector3 targetStartPosition = translateTargetObject.localPosition;

            // Subscribe to interactable's on click so we know the click went through
            bool wasClicked = false;

            interactable.OnClick.AddListener(() => { wasClicked = true; });

            var rightHand = new TestHand(Handedness.Right);

            yield return(rightHand.Show(Vector3.right));

            var rightPokePointer = PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right);

            Assert.IsNotNull(rightPokePointer);
            Assert.IsFalse(rightPokePointer.DestroyOnSourceLost);

            yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, translateTargetObject));

            Assert.IsTrue(wasClicked);
            Assert.IsNotNull(rightPokePointer);
            Assert.IsNull(PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right));

            wasClicked = false;

            yield return(rightHand.Show(Vector3.right));

            // Confirm that we are re-using the same pointer gameobject that was stored in the cache
            Assert.AreEqual(rightPokePointer, PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right));

            yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, translateTargetObject));

            Assert.IsTrue(wasClicked);
            Assert.IsNotNull(rightPokePointer);
            Assert.IsNull(PlayModeTestUtilities.GetPointer <PokePointer>(Handedness.Right));
        }