示例#1
0
    public void OnPointerUp(PointerEventData eventData)
    {
        Debug.Log("Sliding finished");

        TapToPlace.get().shootSliderReleased(1 - GetComponent <Slider>().value);
        GetComponent <Slider>().value = 1;
    }
示例#2
0
    private void Start()
    {
        // Get variables
        TTP          = GetComponent <TapToPlace>();
        interactable = GetComponent <Interactable>();
        focusSelect  = GetComponent <FocusSelect>();

        // When placing ends disable TapToPlace to avoid user being able to move object by clicking it
        TTP.OnPlacingStopped.AddListener(() => TTP.enabled = false);

        // Link focusSelect interaction to interactable.onFocuseReceiver
        // Enable/Disable loading bar on focus
        InteractableOnFocusReceiver focusRec = interactable.AddReceiver <InteractableOnFocusReceiver>();

        focusRec.OnFocusOn.AddListener(focusSelect.StartFocusInteraction);
        focusRec.OnFocusOn.AddListener(() => {
            if (!detailsAnim.gameObject.activeSelf)
            {
                circularLoading.SetActive(true);
            }
        });

        focusRec.OnFocusOff.AddListener(focusSelect.StopFocusInteraction);
        focusRec.OnFocusOff.AddListener(() => circularLoading.SetActive(false));

        // Open details and disable loading bar when focus interaction is complete
        focusSelect.OnHoldFocus.AddListener(OpenDetails);
        focusSelect.OnHoldFocus.AddListener(() => circularLoading.SetActive(false));
    }
示例#3
0
    void Start()
    {
        jointManager = robot.GetComponent <RobotJointManager>();

        if (!useCustomAnimation)
        {
            if (robot.GetComponent <Animator>())
            {
                animator       = robot.GetComponent <Animator>();
                animator.speed = 0f;
            }
            else
            {
                Debug.Log("Robot misses Animator Component");
            }
        }

        if (robot.GetComponent <TapToPlace>())
        {
            tapToPlace = robot.GetComponent <TapToPlace>();
        }
        else
        {
            Debug.Log("Robot misses TapToPlace Component");
        }
    }
示例#4
0
        protected virtual void OnEnable()
        {
            instance = (TapToPlace)target;

            // Main Tap to Place Properties
            autoStart = serializedObject.FindProperty("autoStart");
            defaultPlacementDistance      = serializedObject.FindProperty("defaultPlacementDistance");
            maxRaycastDistance            = serializedObject.FindProperty("maxRaycastDistance");
            useDefaultSurfaceNormalOffset = serializedObject.FindProperty("useDefaultSurfaceNormalOffset");
            surfaceNormalOffset           = serializedObject.FindProperty("surfaceNormalOffset");
            keepOrientationVertical       = serializedObject.FindProperty("keepOrientationVertical");
            rotateAccordingToSurface      = serializedObject.FindProperty("rotateAccordingToSurface");
            debugEnabled     = serializedObject.FindProperty("debugEnabled");
            onPlacingStopped = serializedObject.FindProperty("onPlacingStopped");
            onPlacingStarted = serializedObject.FindProperty("onPlacingStarted");

            // Advanced Properties
            updateLinkedTransformProperty = serializedObject.FindProperty("updateLinkedTransform");
            moveLerpTimeProperty          = serializedObject.FindProperty("moveLerpTime");
            rotateLerpTimeProperty        = serializedObject.FindProperty("rotateLerpTime");
            scaleLerpTimeProperty         = serializedObject.FindProperty("scaleLerpTime");
            maintainScaleProperty         = serializedObject.FindProperty("maintainScale");
            smoothingProperty             = serializedObject.FindProperty("smoothing");
            lifetimeProperty = serializedObject.FindProperty("lifetime");
            magneticSurfaces = serializedObject.FindProperty("magneticSurfaces");
        }
示例#5
0
    void Start()
    {
        if (origamiStepPrefabs.Count == 0)
        {
            Debug.Log("No prefabs defined");
        }

        // instantiate woking Area
        if (workingArea != null)
        {
            workingArea    = Instantiate(workingArea);
            objectPosition = new Vector3(workingArea.transform.position.x, workingArea.transform.position.y + distanceToTable, workingArea.transform.position.z);
        }
        else
        {
            Debug.Log("No working area defined");
        }

        // instantiate start button
        startButton = Instantiate(startButton, objectPosition, Quaternion.identity);
        SetButtonEvent();
        startButton.SetActive(false);

        tapToPlace      = workingArea.transform.Find("WorkingPlane").gameObject.GetComponent <TapToPlace>();
        workingAreaMesh = workingArea.transform.Find("Cube").gameObject.GetComponent <MeshRenderer>();
    }
 // Update is called once per frame
 void Update()
 {
     // Verifie si l'objet est bien chargé, s'il est on verifie si l'enfant a bien un box collider ainsi que le script TapToPlace
     if (gLTFComponentPerso.IsLoaded)
     {
         if (GetComponentInChildren <BoxCollider>() == null)
         {
             foreach (Transform child in transform)
             {
                 child.gameObject.AddComponent <BoxCollider>();
             }
         }
         TapToPlace tapToPlace = GetComponentInChildren <TapToPlace>();
         if (tapToPlace == null)
         {
             foreach (Transform child in transform)
             {
                 child.gameObject.AddComponent <TapToPlace>();
             }
         }
         tapToPlace = GetComponentInChildren <TapToPlace>();
         tapToPlace.AllowMeshVisualizationControl = false;
         tapToPlace.DefaultGazeDistance           = 1f;
     }
 }
 void Start()
 {
     tapToPlace = gameObject.GetComponent <TapToPlace>();
     if (tapToPlace != null && placeableObjectLabel != null)
     {
         AddTapToPlaceListeners();
     }
 }
示例#8
0
    public void Init(Vector3 pos, TapToPlace tap)
    {
        tap.act_callback   = RevertTo;
        transform.position = pos;

        conquertap = tap;
        UpdateActions();
    }
示例#9
0
 public static TapToPlace get()
 {
     if (instance == null)
     {
         instance = new TapToPlace();
     }
     return(instance);
 }
示例#10
0
        public IEnumerator TestTapToPlaceOnClickHead()
        {
            TestUtilities.PlayspaceToOriginLookingForward();

            // Create a cube with Tap to Place attached and Head (default) as the TrackedTargetType
            var tapToPlaceObj = InstantiateTestSolver <TapToPlace>();

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

            // Set hand position
            Vector3 handStartPosition = new Vector3(0, -0.1f, 0.6f);
            var     leftHand          = new TestHand(Handedness.Left);

            yield return(leftHand.Show(handStartPosition));

            // Select Tap to Place Obj
            yield return(leftHand.Click());

            // Make sure the object is being placed
            Assert.True(tapToPlace.IsBeingPlaced);

            // Move the playspace to simulate head movement
            MixedRealityPlayspace.PerformTransformation(p =>
            {
                p.position = Vector3.left * 1.5f;
            });

            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Make sure the target obj has followed the head
            Assert.AreEqual(CameraCache.Main.transform.position.x, tapToPlaceObj.target.transform.position.x, "The tap to place object position.x does not match the camera position.x");

            // Tap to place has a 0.5 sec timer between clicks to make sure a double click does not get registered
            // We need to wait at least 0.5 secs until another click is called or tap to place will ignore the action
            yield return(new WaitForSeconds(0.5f));

            // Click object to stop placement
            yield return(leftHand.Click());

            // Make sure the object is not being placed after the click
            Assert.False(tapToPlace.IsBeingPlaced);

            // Move the playspace to simulate head movement again
            MixedRealityPlayspace.PerformTransformation(p =>
            {
                p.position = Vector3.right;
            });

            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Make sure the target obj is NOT following the head
            Assert.AreNotEqual(CameraCache.Main.transform.position.x, tapToPlaceObj.target.transform.position.x, "The tap to place object position.x matches camera position.x, when it should not");
        }
示例#11
0
    public void StartGame()
    {
        Debug.Log("GameController::StartGame");

        choinka   = SpawnObject();
        choinkaSc = choinka.GetComponent <TapToPlace>();
        //SpawnBombki();
        //SpawnNextEnemy();
    }
示例#12
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);
        }
示例#13
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.gameObject.name == "tlCorner" ||
         collision.collider.gameObject.name == "trCorner" ||
         collision.collider.gameObject.name == "blCorner" ||
         collision.collider.gameObject.name == "brCorner")
     {
         TapToPlace.get().countScore(ballColor);
         gameObject.SetActive(false);
     }
 }
示例#14
0
    IEnumerator FloorSetting(float sec)
    {
        TapToPlace ttp = floorGeter.transform.Find("Cube").gameObject.GetComponent <TapToPlace>();

        yield return(new WaitForSeconds(sec));

        floorGeter.SetActive(true);
        yield return(new WaitForSeconds(2));

        ttp.enabled = false;
    }
示例#15
0
        public IEnumerator TestTapToPlaceOnClickControllerRay()
        {
            TestUtilities.PlayspaceToOriginLookingForward();

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

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

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

            tapToPlaceSolverHandler.TrackedTargetType = TrackedObjectType.ControllerRay;

            // Set hand position
            Vector3 handStartPosition = new Vector3(0, -0.1f, 0.6f);
            var     leftHand          = new TestHand(Handedness.Left);

            yield return(leftHand.Show(handStartPosition));

            Vector3 initialObjPosition = tapToPlaceObj.target.transform.position;

            yield return(leftHand.Click());

            // Make sure the object is being placed after selection
            Assert.True(tapToPlace.IsBeingPlaced);

            // Move hand, object should follow
            yield return(leftHand.Move(Vector3.forward));

            yield return(leftHand.Move(Vector3.up));

            // Make sure the object starting position is different from the current position
            Assert.True(initialObjPosition != tapToPlaceObj.target.transform.position);

            // Tap to place has a 0.5 sec timer between clicks to make sure a double click does not get registered
            // We need to wait at least 0.5 secs until another click is called or tap to place will ignore the action
            yield return(new WaitForSeconds(0.5f));

            // Click to stop the placement
            yield return(leftHand.Click());

            // Make sure the object is not being placed
            Assert.False(tapToPlace.IsBeingPlaced);

            // Get new position of the object after it is placed
            Vector3 newPosition = tapToPlaceObj.target.transform.position;

            // Move hand, the object should NOT move
            yield return(leftHand.Move(Vector3.back, 30));

            Assert.True(newPosition == tapToPlaceObj.target.transform.position);
        }
示例#16
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
示例#17
0
 // Use this for initialization
 void Start()
 {
     initialTransform = transform;
     foreach (Renderer r in gameObject.GetComponentsInChildren <Renderer>())
     {
         r.enabled = false;
     }
     ttp = gameObject.GetComponent <TapToPlace>();
     //y_up = y_down = x_right = x_left = z_front = z_back = y_pos_rot = y_neg_rot = x_pos_rot = x_neg_rot = z_pos_rot = z_neg_rot = false;
     InputManager.Instance.PushFallbackInputHandler(gameObject);
 }
示例#18
0
        public IEnumerator TestTapToPlaceCodeConfigurability()
        {
            TestUtilities.PlayspaceToOriginLookingForward();

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

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

            // Start Placing the object immediately
            tapToPlace.AutoStart = true;

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

            yield return(leftHand.Show(handStartPosition));

            // Make sure the object is being placed after setting AutoStart
            Assert.True(tapToPlace.IsBeingPlaced);

            // Move the playspace to simulate head movement
            MixedRealityPlayspace.PerformTransformation(p =>
            {
                p.position = Vector3.left * 1.5f;
            });

            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Make sure the target obj is following the head
            Assert.AreEqual(CameraCache.Main.transform.position.x, tapToPlaceObj.target.transform.position.x, "The tap to place object position.x does not match the camera position.x");

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

            Assert.False(tapToPlace.IsBeingPlaced);

            // Move the playspace to simulate head movement again
            MixedRealityPlayspace.PerformTransformation(p =>
            {
                p.position = Vector3.right;
            });

            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Make sure the target obj is NOT following the head
            Assert.AreNotEqual(CameraCache.Main.transform.position.x, tapToPlaceObj.target.transform.position.x, "The tap to place object position.x matches the camera position.x, when it should not");
        }
示例#19
0
    public void StartLocateNeobox()
    {
        if (state != OpState.LOCATE_NEOBOX)
        {
            // change state
            SetState(OpState.LOCATE_NEOBOX);

            // start to place
            Helper.TreeEnableRenderer(neoboxPlaceholder);
            TapToPlace ttp = neoboxPlaceholder.GetComponent <TapToPlace>();
            ttp.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
        }
    }
示例#20
0
    public void StartLocateSurfaceBook()
    {
        if (state != OpState.LOCATE_SURFACE_BOOK)
        {
            // change state
            SetState(OpState.LOCATE_SURFACE_BOOK);

            // start to place
            Helper.TreeEnableRenderer(surfaceBookPlaceholder);
            TapToPlace ttp = surfaceBookPlaceholder.GetComponent <TapToPlace>();
            ttp.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
        }
    }
示例#21
0
    void Start()
    {
        if (workingArea != null)
        {
            workingArea = Instantiate(workingArea);
        }

        if (origamiStepPrefabs.Count == 0)
        {
            Debug.Log("No Prefabs defined");
        }

        workingPlane = workingArea.transform.Find("WorkingPlane").gameObject;
        tapToPlace   = workingPlane.GetComponent <TapToPlace>();

        workPlaceMesh = workingArea.transform.Find("Cube").gameObject.GetComponent <MeshRenderer>();
    }
        /// <summary>
        /// Enables <see cref="TapToPlace"/>.
        /// </summary>
        private void EnableTapToPlace()
        {
            // Make sure not already enabled
            if (tapToPlace != null)
            {
                return;
            }

            // Add component
            tapToPlace = gameObject.AddComponent <TapToPlace>();

            // Don't modify the mesh
            tapToPlace.AllowMeshVisualizationControl = false;

            // Collider can't be on while TapToPlace is on
            modelCollider.enabled = false;

            // Start placing
            tapToPlace.IsBeingPlaced = true;
        }
示例#23
0
    void Start()
    {
        // hide something
        Helper.TreeDisableRenderer(neoboxPlaceholder);
        Helper.TreeDisableRenderer(surfaceBookPlaceholder);

        // add delegate
        {
            TapToPlace ttp = neoboxPlaceholder.GetComponent <TapToPlace>();
            ttp.PlacingStart += MainController_onPlacingStart;
            ttp.PlacingEnd   += MainController_onPlacingEnd;
        }
        {
            TapToPlace ttp = surfaceBookPlaceholder.GetComponent <TapToPlace>();
            ttp.PlacingStart += MainController_onPlacingStart;
            ttp.PlacingEnd   += MainController_onPlacingEnd;
        }

        // init state
        SetState(OpState.IDLE);
    }
示例#24
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                startPos = touch.position;
            }

            if (touch.phase == TouchPhase.Moved)
            {
                var deltaX = touch.position.x - startPos.x; //greater than 0 is right and less than zero is left
                var deltaY = touch.position.y - startPos.y; //greater than 0 is up and less than zero is down

                var swipeDistance = Mathf.Abs(deltaX) + Mathf.Abs(deltaY);

                if (swipeDistance > minSwipeDistance && (Mathf.Abs(deltaX) > 0 || Mathf.Abs(deltaY) > 0))
                {
                    CalculateSwipeDirection(deltaX, deltaY);

                    if (direction == SwipeDirection.Up || direction == SwipeDirection.Down)
                    {
                        GetComponent <RawImage>().enabled = true;

                        endPos = touch.position;
                        Vector3 differenceVector = endPos - startPos;

                        imageRect.sizeDelta = new Vector2(differenceVector.magnitude, 15);
                        imageRect.pivot     = new Vector2(0, 0.5f);
                        imageRect.position  = startPos;
                        float angle = Mathf.Atan2(differenceVector.y, differenceVector.x) * Mathf.Rad2Deg;
                        imageRect.rotation = Quaternion.Euler(0, 0, angle);
                    }
                    else if (direction == SwipeDirection.Right || direction == SwipeDirection.Left)
                    {
                        GetComponent <RawImage>().enabled = false;

                        float diff = (touch.position - startPos).magnitude;
                        float p    = diff / (Screen.width * 0.5f);
                        p = Mathf.Min(p, 1);
                        p = direction == SwipeDirection.Right ? p : -p;
                        print("Moving ball " + p);
                        TapToPlace.get().moveMainBall(p);
                    }
                }
            }

            if (touch.phase == TouchPhase.Ended)
            {
                if (direction == SwipeDirection.Up || direction == SwipeDirection.Down)
                {
                    int   height = Screen.height;
                    float diff   = (endPos - startPos).magnitude;
                    float p      = diff / (height / 2.0f);
                    p = Mathf.Min(p, 1);
                    TapToPlace.get().shootSliderReleased(p);
                }

                GetComponent <RawImage>().enabled = false;
            }
        }
    }
示例#25
0
 private void Start()
 {
     TTP = GetComponent <TapToPlace>();
     TTP.OnPlacingStopped.AddListener(() => TTP.enabled = false);
 }
示例#26
0
 void Start()
 {
     arOrigin   = FindObjectOfType <ARSessionOrigin>();
     arRaycast  = FindObjectOfType <ARRaycastManager>();
     tapToPlace = GetComponent <TapToPlace>();
 }
示例#27
0
 // Use this for initialization
 void Start()
 {
     tapScript = (TapToPlace)(FindObjectOfType(typeof(TapToPlace)));
 }
示例#28
0
 void Awake()
 {
     _tapToPlace = GetComponent <TapToPlace>();
     _tapToPlace.SavedAnchorFriendlyName = gameObject.name;
 }
示例#29
0
 private void Start()
 {
     tapManager             = transform.GetComponent <TapToPlace>();
     arRaycastManagerOrigin = FindObjectOfType <ARRaycastManager>();
 }