コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            bool shortcutPressed = true;
            bool shortcutDown    = false;

            // Checks to make sure that all keys are pressed and that one of the required shortcut keys was pressed on this frame
            // before bringing up the shortcut
            foreach (KeyCode key in HelpGuideShortcutKeys)
            {
                shortcutPressed &= KeyInputSystem.GetKey(KeyBinding.FromKey(key));
                shortcutDown    |= KeyInputSystem.GetKeyDown(KeyBinding.FromKey(key));
            }

            if (shortcutPressed && shortcutDown)
            {
                HelpGuideVisual.transform.parent        = CameraCache.Main.transform;
                HelpGuideVisual.transform.rotation      = CameraCache.Main.transform.rotation;
                HelpGuideVisual.transform.localPosition = helpDisplayOffset;

                HelpGuideVisual.transform.parent = null;

                HelpGuideVisual.SetActive(!HelpGuideVisual.activeSelf);
                HelpGuideShortcutTip.SetActive(false);
            }
        }
コード例 #2
0
        public IEnumerator InputSimulationHandsFreeInteraction()
        {
            var iss = PlayModeTestUtilities.GetInputSimulationService();

            TestUtilities.PlayspaceToOriginLookingForward();
            yield return(null);

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

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

            // start click on the cube
            KeyInputSystem.PressKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // release the click on the cube
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Check to see that the cube was clicked on
            Assert.True(wasClicked);
        }
コード例 #3
0
        public IEnumerator InputSimulationArticulatedHandNearGrabbable()
        {
            var iss = PlayModeTestUtilities.GetInputSimulationService();

            TestUtilities.PlayspaceToOriginLookingForward();
            yield return(null);

            // No hands, default cursor should be visible
            Assert.IsTrue(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Head gaze cursor should be visible");

            // Begin right hand manipulation
            KeyInputSystem.PressKey(iss.InputSimulationProfile.ToggleRightHandKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure right hand is tracked
            Assert.True(iss.HandDataRight.IsTracked);

            TestHand hand = new TestHand(Handedness.Right);

            // Head cursor invisible when hand is tracked
            Assert.IsFalse(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Eye gaze cursor should not be visible");
            // Hand ray visible
            var handRayPointer = hand.GetPointer <ShellHandRayPointer>();

            Assert.True(handRayPointer.IsActive, "Hand ray not active");

            // Create grabbable cube
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.AddComponent <NearInteractionGrabbable>();
            cube.transform.localScale = Vector3.one * 0.3f;
            cube.transform.position   = new Vector3(-0.2f, 0.2f, 0.6f);
            yield return(null);

            // Grab pointer is near grabbable
            var grabPointer = hand.GetPointer <SpherePointer>();

            Assert.IsTrue(grabPointer.isActiveAndEnabled, "grab pointer is enabled");
            Assert.IsTrue(grabPointer.IsNearObject, "Grab pointer should be near a grabbable");

            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Head cursor invisible when grab pointer is near grabbable
            Assert.IsFalse(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Eye gaze cursor should not be visible");
            // Hand ray invisible when grab pointer is near grabbable
            Assert.True(!handRayPointer.IsActive, "Hand ray not active");
        }
コード例 #4
0
        public void SetUp()
        {
            PlayModeTestUtilities.Setup();

            // Explicitly enable user input to test in editor behavior.
            InputSimulationService iss = PlayModeTestUtilities.GetInputSimulationService();

            Assert.IsNotNull(iss, "InputSimulationService is null!");
            iss.UserInputEnabled = true;

            cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.localPosition = new Vector3(0, 0, 2);
            cube.transform.localScale    = new Vector3(.2f, .2f, .2f);

            interactable = cube.AddComponent <Interactable>();

            KeyInputSystem.StartKeyInputStimulation();
        }
コード例 #5
0
        // Update is called once per frame
        void Update()
        {
            bool shortcutPressed = true;
            bool shortcutDown    = false;

            // Checks to make sure that all keys are pressed and that one of the required shortcut keys was pressed on this frame
            // before bringing up the shortcut
            foreach (KeyCode key in HelpGuideShortcutKeys)
            {
                shortcutPressed &= KeyInputSystem.GetKey(KeyBinding.FromKey(key));
                shortcutDown    |= KeyInputSystem.GetKeyDown(KeyBinding.FromKey(key));
            }

            if (shortcutPressed && shortcutDown)
            {
                HelpGuideVisual.SetActive(!HelpGuideVisual.activeSelf);
                HelpGuideShortcutTip.SetActive(false);
            }
        }
コード例 #6
0
 public IEnumerator TearDown()
 {
     KeyInputSystem.StopKeyInputSimulation();
     PlayModeTestUtilities.TearDown();
     yield return(null);
 }
コード例 #7
0
        public IEnumerator InputSimulationArticulatedHandGesture()
        {
            var iss = PlayModeTestUtilities.GetInputSimulationService();

            TestUtilities.PlayspaceToOriginLookingForward();
            yield return(null);

            // Check that gaze cursor is initially visible
            Assert.True(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // Begin right hand manipulation
            KeyInputSystem.PressKey(iss.InputSimulationProfile.RightHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure right hand is tracked
            Assert.True(iss.HandDataRight.IsTracked);
            Assert.True(!iss.HandDataLeft.IsTracked);

            // Make sure gaze cursor is not visible
            Assert.True(!CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // start click
            KeyInputSystem.PressKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure correct hand is pinching
            Assert.True(iss.HandDataRight.IsPinching);
            Assert.True(!iss.HandDataLeft.IsPinching);

            // release the click
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure hands are not pinching anymore
            Assert.True(!iss.HandDataRight.IsPinching);
            Assert.True(!iss.HandDataLeft.IsPinching);

            // End right hand manipulation
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.RightHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            // Wait for the hand hide timeout to hide the hands
            yield return(new WaitForSeconds(iss.InputSimulationProfile.HandHideTimeout + 0.1f));

            // Make sure right hand is not tracked
            Assert.True(!iss.HandDataRight.IsTracked);
            Assert.True(!iss.HandDataLeft.IsTracked);

            // Check that gaze cursor is visible
            Assert.True(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // Repeat with left hand
            // Begin left hand manipulation
            KeyInputSystem.PressKey(iss.InputSimulationProfile.LeftHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure left hand is tracked
            Assert.True(!iss.HandDataRight.IsTracked);
            Assert.True(iss.HandDataLeft.IsTracked);

            // Make sure gaze cursor is not visible
            Assert.True(!CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // start click
            KeyInputSystem.PressKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure correct hand is pinching
            Assert.True(!iss.HandDataRight.IsPinching);
            Assert.True(iss.HandDataLeft.IsPinching);

            // release the click
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure hands are not pinching anymore
            Assert.True(!iss.HandDataRight.IsPinching);
            Assert.True(!iss.HandDataLeft.IsPinching);


            // End left hand manipulation
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.LeftHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            // Wait for the hand hide timeout to hide the hands
            yield return(new WaitForSeconds(iss.InputSimulationProfile.HandHideTimeout + 0.1f));

            // Make sure left hand is not tracked
            Assert.True(!iss.HandDataRight.IsTracked);
            Assert.True(!iss.HandDataLeft.IsTracked);

            // Check that gaze cursor is visible
            Assert.True(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // Lastly with 2 hands
            // Begin hand manipulation
            KeyInputSystem.PressKey(iss.InputSimulationProfile.RightHandManipulationKey);
            KeyInputSystem.PressKey(iss.InputSimulationProfile.LeftHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure hands are tracked
            Assert.True(iss.HandDataRight.IsTracked);
            Assert.True(iss.HandDataLeft.IsTracked);

            // Make sure gaze cursor is not visible
            Assert.True(!CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // start click
            KeyInputSystem.PressKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure hands are pinching
            Assert.True(iss.HandDataRight.IsPinching);
            Assert.True(iss.HandDataLeft.IsPinching);

            // release the click
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.InteractionButton);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure hands are not pinching anymore
            Assert.True(!iss.HandDataRight.IsPinching);
            Assert.True(!iss.HandDataLeft.IsPinching);


            // End hand manipulation
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.RightHandManipulationKey);
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.LeftHandManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            // Wait for the hand hide timeout to hide the hands
            yield return(new WaitForSeconds(iss.InputSimulationProfile.HandHideTimeout + 0.1f));


            // Make sure hands are not tracked
            Assert.True(!iss.HandDataRight.IsTracked);
            Assert.True(!iss.HandDataLeft.IsTracked);

            // Check that gaze cursor is visible
            Assert.True(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);
        }
コード例 #8
0
 public void TearDown()
 {
     KeyInputSystem.StopKeyInputSimulation();
     PlayModeTestUtilities.TearDown();
 }
コード例 #9
0
        public IEnumerator InputSimulationBothMotionControllerButtonState()
        {
            var iss = PlayModeTestUtilities.GetInputSimulationService();
            // Switch to motion controller
            var oldHandSimMode = iss.ControllerSimulationMode;

            iss.ControllerSimulationMode = ControllerSimulationMode.MotionController;
            TestUtilities.PlayspaceToOriginLookingForward();
            yield return(null);

            // Check that gaze cursor is initially visible
            Assert.True(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // Begin both motion controller manipulation
            KeyInputSystem.PressKey(iss.InputSimulationProfile.LeftControllerManipulationKey);
            KeyInputSystem.PressKey(iss.InputSimulationProfile.RightControllerManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure both motion controllers are tracked
            Assert.True(iss.MotionControllerDataLeft.IsTracked);
            Assert.True(iss.MotionControllerDataRight.IsTracked);

            // Make sure gaze cursor is not visible
            Assert.True(!CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible);

            // press trigger
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerTriggerKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure both motion controllers are selecting
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsSelecting);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsSelecting);

            // release the button
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerTriggerKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure motion controllers are not selecting anymore
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsSelecting);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsSelecting);

            // press grab
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerGrabKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure both motion controllers are grabbing
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsGrabbing);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsGrabbing);

            // release the button
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerGrabKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure motion controllers are not grabbing anymore
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsGrabbing);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsGrabbing);

            // press menu
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerMenuKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure both motion controllers are pressing menu
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsPressingMenu);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsPressingMenu);

            // release the button
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerMenuKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure motion controllers are not pressing menu anymore
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsPressingMenu);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsPressingMenu);

            // press all three buttons
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerTriggerKey);
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerGrabKey);
            KeyInputSystem.PressKey(iss.InputSimulationProfile.MotionControllerMenuKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // Make sure both motion controllers are pressing three buttons
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsSelecting);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsSelecting);
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsGrabbing);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsGrabbing);
            Assert.True(iss.MotionControllerDataLeft.ButtonState.IsPressingMenu);
            Assert.True(iss.MotionControllerDataRight.ButtonState.IsPressingMenu);

            // release the button
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerTriggerKey);
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerGrabKey);
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.MotionControllerMenuKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            yield return(null);

            // Make sure motion controllers are not pressing three buttons anymore
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsSelecting);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsSelecting);
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsGrabbing);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsGrabbing);
            Assert.True(!iss.MotionControllerDataLeft.ButtonState.IsPressingMenu);
            Assert.True(!iss.MotionControllerDataRight.ButtonState.IsPressingMenu);


            // End both motion controller manipulation
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.LeftControllerManipulationKey);
            KeyInputSystem.ReleaseKey(iss.InputSimulationProfile.RightControllerManipulationKey);
            yield return(null);

            KeyInputSystem.AdvanceSimulation();
            // Wait for the motion controller hide timeout to hide the motion controllers
            yield return(new WaitForSeconds(iss.InputSimulationProfile.ControllerHideTimeout + 0.1f));

            // Make sure both motion controllers are not tracked
            Assert.True(!iss.MotionControllerDataLeft.IsTracked);
            Assert.True(!iss.MotionControllerDataRight.IsTracked);


            // Restore the input simulation profile
            iss.ControllerSimulationMode = oldHandSimMode;
            yield return(null);
        }
コード例 #10
0
 public override IEnumerator TearDown()
 {
     KeyInputSystem.StopKeyInputSimulation();
     yield return(base.TearDown());
 }