public IEnumerator TestOverrideFocusDetails()
        {
            PlayModeTestUtilities.Setup();

            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            yield return(null);

            var focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            var pointer = new TestPointer();

            Assert.IsFalse(focusProvider.TryGetFocusDetails(pointer, out var focusDetails));
            Assert.IsFalse(focusProvider.TryOverrideFocusDetails(pointer, new Physics.FocusDetails()));

            focusProvider.RegisterPointer(pointer);
            yield return(null);

            Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails));
            Assert.IsNull(focusDetails.Object);

            var newFocusDetails = new Physics.FocusDetails();

            newFocusDetails.Object      = cube;
            newFocusDetails.RayDistance = 10;
            newFocusDetails.Point       = new Vector3(1, 2, 3);
            Assert.IsTrue(focusProvider.TryOverrideFocusDetails(pointer, newFocusDetails));

            Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails));
            Assert.AreEqual(newFocusDetails.Object, focusDetails.Object);
            Assert.AreEqual(newFocusDetails.RayDistance, focusDetails.RayDistance);
            Assert.AreEqual(newFocusDetails.Point, focusDetails.Point);
            Assert.AreEqual(newFocusDetails.Object, focusProvider.GetFocusedObject(pointer));
        }
        public void SetupFocusProviderRaycastTests()
        {
            PlayModeTestUtilities.Setup();

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath("dc3b0cf66c0615e4c81d979f35d51eaa"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
        }
Esempio n. 3
0
        public void SetupFocusProviderRaycastTests()
        {
            PlayModeTestUtilities.Setup();

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(Path.Combine("Assets", "MixedRealityToolkit.Tests", "PlayModeTests", "Prefabs", "FocusProviderRaycastTest.prefab"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
        }
        public void ShutdownFocusProviderRaycastTests()
        {
            if (raycastTestPrefabInstance)
            {
                Object.DestroyImmediate(raycastTestPrefabInstance);
                raycastTestPrefabInstance = null;
            }

            focusProvider.UnregisterPointer(pointer);
            focusProvider = null;
            pointer       = null;

            PlayModeTestUtilities.TearDown();
        }
        public override IEnumerator TearDown()
        {
            if (raycastTestPrefabInstance)
            {
                Object.DestroyImmediate(raycastTestPrefabInstance);
                raycastTestPrefabInstance = null;
            }

            focusProvider.UnregisterPointer(pointer);
            focusProvider = null;
            pointer       = null;

            yield return(base.TearDown());
        }
        public override IEnumerator Setup()
        {
            yield return(base.Setup());

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath("dc3b0cf66c0615e4c81d979f35d51eaa"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
            yield return(null);
        }