|
11 | 11 | // play mode tests in this check.
|
12 | 12 |
|
13 | 13 | using Microsoft.MixedReality.Toolkit.Input;
|
| 14 | +using Microsoft.MixedReality.Toolkit.Teleport; |
14 | 15 | using Microsoft.MixedReality.Toolkit.Utilities;
|
15 | 16 | using NUnit.Framework;
|
16 | 17 | using System;
|
@@ -281,6 +282,50 @@ public IEnumerator TestTeleport()
|
281 | 282 | leftHand.Hide();
|
282 | 283 | }
|
283 | 284 |
|
| 285 | + |
| 286 | + /// <summary> |
| 287 | + /// Tests that the teleport pointer functions as expected |
| 288 | + /// </summary> |
| 289 | + [UnityTest] |
| 290 | + public IEnumerator TestTeleportLayers() |
| 291 | + { |
| 292 | + var iss = PlayModeTestUtilities.GetInputSimulationService(); |
| 293 | + |
| 294 | + // Create a floor and make sure it's below the camera |
| 295 | + var floor = GameObject.CreatePrimitive(PrimitiveType.Plane); |
| 296 | + floor.transform.position = -0.5f * Vector3.up; |
| 297 | + |
| 298 | + // Bring out the right hand and set it to the teleport gesture |
| 299 | + TestUtilities.PlayspaceToOriginLookingForward(); |
| 300 | + float initialForwardPosition = MixedRealityPlayspace.Position.z; |
| 301 | + |
| 302 | + TestHand rightHand = new TestHand(Handedness.Right); |
| 303 | + |
| 304 | + // Make sure the hand is in front of the camera |
| 305 | + yield return rightHand.Show(Vector3.forward * 0.6f); |
| 306 | + rightHand.SetRotation(Quaternion.identity); |
| 307 | + |
| 308 | + yield return rightHand.SetGesture(ArticulatedHandPose.GestureId.TeleportStart); |
| 309 | + // Wait for the hand to animate |
| 310 | + yield return PlayModeTestUtilities.WaitForInputSystemUpdate(); |
| 311 | + yield return new WaitForSeconds(1.0f / iss.InputSimulationProfile.HandGestureAnimationSpeed + 0.1f); |
| 312 | + |
| 313 | + TeleportPointer teleportPointer = rightHand.GetPointer<TeleportPointer>(); |
| 314 | + |
| 315 | + floor.layer = LayerMask.NameToLayer("Default"); |
| 316 | + yield return PlayModeTestUtilities.WaitForInputSystemUpdate(); |
| 317 | + Assert.AreEqual(teleportPointer.TeleportSurfaceResult, Physics.TeleportSurfaceResult.Valid); |
| 318 | + |
| 319 | + floor.layer = LayerMask.NameToLayer("Ignore Raycast"); |
| 320 | + yield return PlayModeTestUtilities.WaitForInputSystemUpdate(); |
| 321 | + Assert.AreEqual(rightHand.GetPointer<TeleportPointer>().TeleportSurfaceResult, Physics.TeleportSurfaceResult.Invalid); |
| 322 | + |
| 323 | + floor.layer = LayerMask.NameToLayer("UI"); |
| 324 | + yield return PlayModeTestUtilities.WaitForInputSystemUpdate(); |
| 325 | + Assert.AreEqual(rightHand.GetPointer<TeleportPointer>().TeleportSurfaceResult, Physics.TeleportSurfaceResult.None); |
| 326 | + |
| 327 | + } |
| 328 | + |
284 | 329 | /// <summary>
|
285 | 330 | /// Tests that rays can be turned on and off
|
286 | 331 | /// </summary>
|
|
0 commit comments