示例#1
0
 /// <summary>
 /// Sets pointer behavior to mimic HoloLens 2
 /// PokePointer will be Default
 /// GrabPointer will be Default
 /// HandRayPointer will be Default
 /// MotionControllerRayPointer will be off
 /// GazePointer will be Off
 /// </summary>
 public void SetHoloLens2()
 {
     PointerUtils.SetHandPokePointerBehavior(PointerBehavior.Default, Handedness.Any);
     PointerUtils.SetHandGrabPointerBehavior(PointerBehavior.Default, Handedness.Any);
     PointerUtils.SetHandRayPointerBehavior(PointerBehavior.Default, Handedness.Any);
     PointerUtils.SetMotionControllerRayPointerBehavior(PointerBehavior.AlwaysOff, Handedness.Any);
     PointerUtils.SetGazePointerBehavior(PointerBehavior.AlwaysOff);
 }
        public IEnumerator TestGrab()
        {
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.AddComponent <NearInteractionGrabbable>();
            cube.transform.position = Vector3.forward;
            TestUtilities.PlayspaceToOriginLookingForward();

            TestHand rightHand = new TestHand(Handedness.Right);
            TestHand leftHand  = new TestHand(Handedness.Left);

            TestContext.Out.WriteLine("Show both hands near grabbable cube");
            yield return(rightHand.Show(cube.transform.position));

            yield return(leftHand.Show(cube.transform.position));

            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            PointerStateContainer grabOn = new PointerStateContainer()
            {
                GazePointerEnabled   = false,
                GGVPointerEnabled    = null,
                PokePointerEnabled   = false,
                SpherePointerEnabled = true,
                LinePointerEnabled   = false
            };

            EnsurePointerStates(Handedness.Right, grabOn);
            EnsurePointerStates(Handedness.Left, grabOn);

            TestContext.Out.WriteLine("Turn off grab pointer right hand");
            PointerUtils.SetHandGrabPointerBehavior(PointerBehavior.AlwaysOff, Handedness.Right);
            yield return(null);

            PointerStateContainer grabOff = new PointerStateContainer()
            {
                GazePointerEnabled   = false,
                GGVPointerEnabled    = null,
                PokePointerEnabled   = false,
                SpherePointerEnabled = false,
                LinePointerEnabled   = true
            };

            EnsurePointerStates(Handedness.Right, grabOff);
            EnsurePointerStates(Handedness.Left, grabOn);

            TestContext.Out.WriteLine("Turn off grab pointer both hands");
            PointerUtils.SetHandGrabPointerBehavior(PointerBehavior.AlwaysOff);
            yield return(null);

            EnsurePointerStates(Handedness.Right, grabOff);
            EnsurePointerStates(Handedness.Left, grabOff);
        }
示例#3
0
 /// <summary>
 /// Sets the <see cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/> for the grab pointer to be AlwaysOff
 /// <param name="isEnabled">If true, behavior will be set to Default.
 /// Otherwise it will be set to AlwaysOff</param>
 /// </summary>
 public void SetGrabEnabled(bool isEnabled)
 {
     PointerUtils.SetHandGrabPointerBehavior(isEnabled ? PointerBehavior.Default : PointerBehavior.AlwaysOff, Handedness.Any);
 }