public IEnumerator TestClickEvents()
        {
            PlayModeTestUtilities.PushControllerSimulationProfile();
            PlayModeTestUtilities.SetControllerSimulationMode(ControllerSimulationMode.HandGestures);

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

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

            var testHand = new TestHand(Handedness.Right);

            yield return(testHand.Show(Vector3.zero));

            CameraCache.Main.transform.LookAt(interactable.transform);
            yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            yield return(testHand.Hide());

            Assert.True(wasClicked);

            PlayModeTestUtilities.PopControllerSimulationProfile();
        }
예제 #2
0
 public IEnumerator Setup()
 {
     PlayModeTestUtilities.Setup();
     PlayModeTestUtilities.PushControllerSimulationProfile();
     TestUtilities.PlayspaceToOriginLookingForward();
     yield return(null);
 }
예제 #3
0
        public IEnumerator TestAssembleInteractableAndFarManip()
        {
            GameObject  pinchSliderObject;
            PinchSlider slider;

            // This should not throw exception
            AssembleSlider(Vector3.forward, Vector3.zero, out pinchSliderObject, out slider);

            Debug.Assert(slider.SliderValue == 0.5, "Slider should have value 0.5 at start");

            // Set up ggv simulation
            PlayModeTestUtilities.PushControllerSimulationProfile();
            PlayModeTestUtilities.SetControllerSimulationMode(ControllerSimulationMode.HandGestures);

            var     rightHand  = new TestHand(Handedness.Right);
            Vector3 initialPos = new Vector3(0.05f, 0, 1.0f);

            yield return(rightHand.Show(initialPos));

            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            yield return(rightHand.Move(new Vector3(0.1f, 0, 0)));

            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            yield return(rightHand.Hide());

            Assert.That(slider.SliderValue, Is.GreaterThan(0.5));

            // clean up
            GameObject.Destroy(pinchSliderObject);
            PlayModeTestUtilities.PopControllerSimulationProfile();
        }
예제 #4
0
        public IEnumerator ScaleViaHoloLens1Interaction()
        {
            var bbox = InstantiateSceneAndDefaultBbox();

            yield return(null);

            yield return(null);

            var bounds      = bbox.GetComponent <BoxCollider>().bounds;
            var startCenter = new Vector3(0, 0, 1.5f);
            var startSize   = new Vector3(.5f, .5f, .5f);

            TestUtilities.AssertAboutEqual(bounds.center, startCenter, "bbox incorrect center at start");
            TestUtilities.AssertAboutEqual(bounds.size, startSize, "bbox incorrect size at start");

            PlayModeTestUtilities.PushControllerSimulationProfile();
            PlayModeTestUtilities.SetControllerSimulationMode(ControllerSimulationMode.HandGestures);

            CameraCache.Main.transform.LookAt(bbox.ScaleCorners[3].transform);

            var      startHandPos = CameraCache.Main.transform.TransformPoint(new Vector3(0.1f, 0f, 1.5f));
            TestHand rightHand    = new TestHand(Handedness.Right);

            yield return(rightHand.Show(startHandPos));

            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            // After pinching, center should remain the same
            var afterPinchbounds = bbox.GetComponent <BoxCollider>().bounds;

            TestUtilities.AssertAboutEqual(afterPinchbounds.center, startCenter, "bbox incorrect center after pinch");
            TestUtilities.AssertAboutEqual(afterPinchbounds.size, startSize, "bbox incorrect size after pinch");

            var delta = new Vector3(0.1f, 0.1f, 0f);

            yield return(rightHand.Move(delta));

            var endBounds = bbox.GetComponent <BoxCollider>().bounds;

            TestUtilities.AssertAboutEqual(endBounds.center, new Vector3(0.033f, 0.033f, 1.467f), "endBounds incorrect center");
            TestUtilities.AssertAboutEqual(endBounds.size, Vector3.one * .561f, "endBounds incorrect size", 0.02f);

            GameObject.Destroy(bbox.gameObject);
            // Wait for a frame to give Unity a change to actually destroy the object
            yield return(null);

            // Restore the input simulation profile
            PlayModeTestUtilities.PopControllerSimulationProfile();

            yield return(null);
        }
        public IEnumerator TestToggleEvents()
        {
            PlayModeTestUtilities.PushControllerSimulationProfile();
            PlayModeTestUtilities.SetControllerSimulationMode(ControllerSimulationMode.HandGestures);

            var toggleReceiver = interactable.AddReceiver <InteractableOnToggleReceiver>();

            interactable.transform.position = Vector3.forward * 2f;
            interactable.NumOfDimensions    = 2;
            interactable.CanSelect          = true;
            interactable.CanDeselect        = true;
            bool didSelect   = false;
            bool didUnselect = false;

            toggleReceiver.OnSelect.AddListener(() => didSelect     = true);
            toggleReceiver.OnDeselect.AddListener(() => didUnselect = true);

            var testHand = new TestHand(Handedness.Right);

            yield return(testHand.Show(Vector3.forward));

            CameraCache.Main.transform.LookAt(interactable.transform.position);

            yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            yield return(testHand.Click());

            yield return(testHand.Click());

            yield return(testHand.Hide());

            Assert.True(didSelect, "Toggle select did not fire");
            Assert.True(didUnselect, "Toggle unselect did not fire");

            PlayModeTestUtilities.PopControllerSimulationProfile();
        }