Пример #1
0
        public IEnumerator TestTapToPlaceColliderTests()
        {
            TestUtilities.PlayspaceToOriginLookingForward();

            // Create a scene with 2 cubes
            GameObject colliderObj1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

            colliderObj1.transform.localScale = new Vector3(0.3f, 0.3f, 0.05f);
            colliderObj1.transform.position   = new Vector3(0.3f, 0, 1.5f);

            GameObject colliderObj2 = GameObject.CreatePrimitive(PrimitiveType.Cube);

            colliderObj2.transform.localScale = new Vector3(0.3f, 0.3f, 0.05f);
            colliderObj2.transform.position   = new Vector3(-0.3f, 0, 1.5f);

            // Create a cube with Tap to Place attached
            var tapToPlaceObj = InstantiateTestSolver <TapToPlace>();

            tapToPlaceObj.target.transform.position = Vector3.forward * 2;
            TapToPlace tapToPlace = tapToPlaceObj.solver as TapToPlace;

            // Switching the TrackedTargetType to Controller Ray
            SolverHandler tapToPlaceSolverHandler = tapToPlaceObj.handler;

            tapToPlaceSolverHandler.TrackedTargetType = TrackedObjectType.ControllerRay;

            Vector3 handStartPosition = new Vector3(0, -0.15f, 0.5f);
            var     leftHand          = new TestHand(Handedness.Left);

            yield return(leftHand.Show(handStartPosition));

            // Start the placement via code instead of click from the hand
            tapToPlace.StartPlacement();
            yield return(null);

            Assert.True(tapToPlace.IsBeingPlaced);

            // Move hand, object should follow
            yield return(leftHand.Move(new Vector3(-0.15f, 0, 0), 30));

            Assert.True(tapToPlaceObj.target.transform.position.z < colliderObj1.transform.position.z);

            yield return(leftHand.Move(new Vector3(0.15f, 0, 0), 30));

            Assert.True(tapToPlaceObj.target.transform.position.z > colliderObj1.transform.position.z);

            yield return(leftHand.Move(new Vector3(0.15f, 0, 0), 30));

            Assert.True(tapToPlaceObj.target.transform.position.z < colliderObj1.transform.position.z);

            // Stop the placement via code instead of click from the hand
            tapToPlace.StopPlacement();

            Assert.False(tapToPlace.IsBeingPlaced);
        }
        public void StartIndicator()
        {
            // Ensure placing visual when enabled
            placingVisual.SetActive(true);
            confirmingVisual.SetActive(false);
            saveLocationDialog.SetActive(false);

            // Subscribe to event
            tapToPlace.StartPlacement();
            tapToPlace.OnPlacingStopped.AddListener(OnPlacingStopped);
        }
Пример #3
0
 public void Move()
 {
     TTP.enabled = true;
     TTP.StartPlacement();
 }