Esempio n. 1
0
 private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay)
 {
     if (FocusedObject != null)
     {
         FocusedObject.SendMessage("OnAirTapped", SendMessageOptions.RequireReceiver);
     }
 }
Esempio n. 2
0
        private void OnTap()
        {
            /*if (FocusedObject != null && PreviousObject == null && FocusedObject.GetComponent<PerformAction>().GotTransform == false)
             *          {
             *                  PreviousObject = FocusedObject.name;
             *                  FocusedObject.SendMessage("ObjectAction",FocusedObject.name);
             *
             *          } else if (FocusedObject != null && FocusedObject.name == PreviousObject && FocusedObject.GetComponent<PerformAction>().GotTransform == true)
             * {
             *                  PreviousObject = null;
             *                  FocusedObject.SendMessage("ObjectAction",FocusedObject.name);
             *
             * }*/

            try {
                if (FocusedObject != null && FocusedObject.GetComponent <PerformAction> ().GotTransform == false && FocusedObject.transform.parent != GameObject.Find("Chair").transform)
                {
                    //PreviousObject = FocusedObject.name;
                    //(Behaviour)FocusedObject.GetComponent(Halo);
                    FocusedObject.SendMessage("ObjectAction", FocusedObject.name);
                }
            } catch (NullReferenceException e) {
                print(e.Message);
            }
        }
Esempio n. 3
0
 private void OnTap()
 {
     if (FocusedObject != null)
     {
         FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
     }
 }
Esempio n. 4
0
 private void OnTap()
 {
     if (FocusedObject != null)
     {
         FocusedObject.SendMessage("OnSelect");
     }
 }
Esempio n. 5
0
 private void OnTap()
 {
     if (!blockTapEvents && FocusedObject != null)
     {
         tapEvent = true;
         FocusedObject.SendMessage("OnSelect");
     }
 }
Esempio n. 6
0
 private void OnRecognitionStarted()
 {
     if (FocusedObject != null)
     {
         hasRecognitionStarted = true;
         FocusedObject.SendMessage("OnPressed", SendMessageOptions.DontRequireReceiver);
     }
 }
 /// <summary>
 /// Throws OnDoubleTap.
 /// </summary>
 private void OnDoubleTap()
 {
     Debug.Log("DoubleTap" + FocusedObject.name);
     if (FocusedObject != null)
     {
         FocusedObject.SendMessage("OnDoubleTap", SendMessageOptions.DontRequireReceiver);
     }
 }
Esempio n. 8
0
        private void OnRecognitionEndeded()
        {
            if (FocusedObject != null && hasRecognitionStarted)
            {
                FocusedObject.SendMessage("OnReleased", SendMessageOptions.DontRequireReceiver);
            }

            hasRecognitionStarted = false;
        }
Esempio n. 9
0
 /// <summary>
 /// Throws OnSelect.
 /// </summary>
 private void OnTap()
 {
     if (FocusedObject != null)
     {
         //Added this to play nice with selectable
         var eventData = new BaseEventData(EventSystem.current);
         FocusedObject.SendMessage("OnSelect", eventData, SendMessageOptions.DontRequireReceiver);
         FocusedObject.SendMessage("OnPointerClick", new PointerEventData(EventSystem.current), SendMessageOptions.DontRequireReceiver);
     }
 }
Esempio n. 10
0
        private void OnTap()
        {
            if (FocusedObject != null)
            {
                Debug.Log("foo");
                FocusedObject.SendMessage("OnSelect");

                GetComponent <NavMeshAgent>().SetDestination(GazeManager.Instance.Position);
            }
        }
Esempio n. 11
0
    private void CursorUpdate()
    {
        oldFocusedObject = FocusedObject;
        switch (priority)
        {
        case CursorFocusPriority.Hand:
            if (HandManager.instance.HandDetected)
            {
                HandUpdate();
            }
            else
            {
                GazeUpdate();
            }
            break;

        case CursorFocusPriority.Gaze:
            GazeUpdate();
            break;

        default:
            break;
        }

        // Message sending should be suppressed while dragging
        if (!Dragging)
        {
            // Send Messages
            if (FocusedObject != oldFocusedObject)
            {
                if (FocusedObject != null)
                {
                    FocusedObject.SendMessage("OnFocusEnter", this, SendMessageOptions.DontRequireReceiver);
                    HUDLogController.QuickMessage("Focus Enter " + FocusedObject.name);
                }
                if (oldFocusedObject != null)
                {
                    oldFocusedObject.SendMessage("OnFocusExit", this, SendMessageOptions.DontRequireReceiver);
                    HUDLogController.QuickMessage("Focus Exit " + oldFocusedObject.name);
                }
            }
            else
            {
                if (FocusedObject != null)
                {
                    FocusedObject.SendMessage("OnFocusOver", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        else
        {
            DraggedObject.transform.position = mesh.transform.position;
        }
    }
Esempio n. 12
0
        /// <summary>
        /// Calculates the Raycast hit position and normal.
        /// </summary>
        private void UpdateRaycast()
        {
            // Get the raycast hit information from Unity's physics system.
            RaycastHit hitInfo;

            if (GazeStabilization != null)
            {
                Hit = Physics.Raycast(GazeStabilization.StableHeadRay, out hitInfo, MaxGazeDistance, RaycastLayerMask);
            }
            else
            {
                Hit = Physics.Raycast(gazeOrigin, gazeDirection, out hitInfo, MaxGazeDistance, RaycastLayerMask);
            }

            GameObject oldFocusedObject = FocusedObject;

            // Update the HitInfo property so other classes can use this hit information.
            HitInfo = hitInfo;

            if (Hit)
            {
                // If the raycast hits a hologram, set the position and normal to match the intersection point.
                Position        = hitInfo.point;
                Normal          = hitInfo.normal;
                lastHitDistance = hitInfo.distance;
                FocusedObject   = hitInfo.collider.gameObject;
            }
            else
            {
                // If the raycast does not hit a hologram, default the position to last hit distance in front of the user,
                // and the normal to face the user.
                Position      = gazeOrigin + (gazeDirection * lastHitDistance);
                Normal        = -gazeDirection;
                FocusedObject = null;
            }

            // Check if the currently hit object has changed
            if (oldFocusedObject != FocusedObject)
            {
                if (oldFocusedObject != null)
                {
                    oldFocusedObject.SendMessage("OnGazeLeave", SendMessageOptions.DontRequireReceiver);
                }
                if (FocusedObject != null)
                {
                    FocusedObject.SendMessage("OnGazeEnter", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Throws OnSelect.
 /// </summary>
 private void OnTap()
 {
     SpawnManager.Instance.Tap();
     if (FocusedObject != null)
     {
         FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
         if (FocusedObject.GetComponent <ModalObject>() == null)
         {
             SelectionManager.Instance.DeselectAll();
         }
     }
     else
     {
         SelectionManager.Instance.DeselectAll();
     }
 }
Esempio n. 14
0
        private void OnTap()
        {
            if (SceneManager.Instance.currentSceneState.Value.SceneModeType == SceneModeType.Placement)
            {
                SceneManager.Instance.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver);
            }

            if (SceneManager.Instance.CurrentInteractiveObject() != null)
            {
                SceneManager.Instance.CurrentInteractiveObject().GetComponent <SnapToPosition>().SendMessage("OnSelect");
            }
            else if (FocusedObject != null)
            {
                FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
            }
        }
Esempio n. 15
0
        private void OnTap(InteractionSourceKind source, int tapCount, Ray ray)
        {
            if (!begin)
            {
                return;
            }

            // 需要给目标物体发个指令
            if (FocusedObject != null)
            {
                FocusedObject.SendMessage("OnTapOnObject", SendMessageOptions.DontRequireReceiver);
            }

            if (cbTap != null)
            {
                cbTap(tapCount);
            }
        }
Esempio n. 16
0
        private void _RayCastForObject()
        {
            oldFocusObject = FocusedObject;

            bool       hasObj = false;
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo, 1000, layerMask))
            {
                FocusedObject = hitInfo.collider.gameObject;
                hitPoint      = hitInfo.point;
                hitNormal     = hitInfo.normal;
                hitCollider   = hitInfo.collider;
                //Debug.Log("focus:" + FocusedObject);

                hasObj = true;
            }

            if (!hasObj)
            {
                FocusedObject = null;
                hitPoint      = headPosition + gazeDirection * 5;
                hitNormal     = gazeDirection;
                hitCollider   = null;
            }

            if (oldFocusObject != FocusedObject)
            {
                // 需要发送移入、移出消息
                if (oldFocusObject != null)
                {
                    oldFocusObject.SendMessage("OnGazeExitObject", SendMessageOptions.DontRequireReceiver);
                }

                if (FocusedObject != null)
                {
                    FocusedObject.SendMessage("OnGazeEnterObject", SendMessageOptions.DontRequireReceiver);
                }

                oldFocusObject = FocusedObject;
            }
        }
Esempio n. 17
0
    void UpdateRaycast()
    {
        RaycastHit hitInfo;

        Hit = Physics.Raycast(gazeOrigin, gazeDirection, out hitInfo, MaxGazeDistance, RaycastLayerMask);

        GameObject oldFocusedObject = FocusedObject;

        HitInfo = hitInfo;
        //如果射线检测到凝视目标,记录相应信息
        if (Hit)
        {
            Position        = hitInfo.point;
            Normal          = hitInfo.normal;
            lastHitDistance = hitInfo.distance;
            FocusedObject   = hitInfo.collider.gameObject;
        }
        //如果没检测到凝视目标,赋值默认值
        else
        {
            Position      = gazeOrigin + (gazeDirection * lastHitDistance);
            Normal        = -gazeDirection;
            FocusedObject = null;
        }

        if (oldFocusedObject != FocusedObject)
        {
            if (oldFocusedObject != null)
            {
                oldFocusedObject.SendMessage("OnGazeLeave", SendMessageOptions.DontRequireReceiver);
            }
            if (FocusedObject != null)
            {
                FocusedObject.SendMessage("OnGazeEnter", SendMessageOptions.DontRequireReceiver);
            }
        }
    }
Esempio n. 18
0
 /// <summary>
 /// Throws OnSelect. Will begin drawing a line by activating the draw() subroutine in the current
 /// sketcher, then will overwrite the reference to that sketcher with a newly instantiated on when done
 /// </summary>
 private void OnTap()
 {
     if (FocusedObject != null && FocusedObject.CompareTag("picker"))
     {
         FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
     }
     else
     {
         if (isDrawing)
         {
             mSketcher.stopDrawing();
             pastSketches.Add(mSketcher);
             mSketcher = ((GameObject)Instantiate(mSketchPrefab)).GetComponent <Sketcher>();
             mSketcher.GetComponent <LineRenderer>().SetColors(mWarehouse.currentColor, mWarehouse.currentColor);
             mSketcher.cursor     = cursor;
             mWarehouse.mSketcher = mSketcher;
         }
         else
         {
             mSketcher.startDrawing();
         }
         isDrawing = !isDrawing;
     }
 }
        /// <summary>
        /// Throws OnSelect.
        /// </summary>
        private void OnTap()
        {
            if (FocusedObject != null)
            {
                FocusedObject.SendMessage("OnSelect", SendMessageOptions.DontRequireReceiver);
            }

            if (FocusedObject.tag == "Chest")
            {
                return;
            }
            RaycastHit hitInfo;
            bool       onHit = Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo, 5.0f, toSpawnLayout);

            if (onHit)
            {
                GameObject go = Instantiate <GameObject>(toSpawn, hitInfo.point + hitInfo.normal * 0.05f, Quaternion.identity);
                go.transform.localScale = Vector3.one * 0.1f;
                go.GetComponent <ChestController>().rotate = false;
                go.GetComponent <OnSelectEvent>().enabled  = true;
                go.GetComponent <SimpleTagalong>().enabled = false;
                go.transform.up = hitInfo.normal;
            }
        }
Esempio n. 20
0
    private void UpdateRaycast()
    {
        // Set the old focused gameobject.
        oldFocusedObject = FocusedObject;
        RaycastHit hitInfo;

        // Initialise Raycasting.
        Hit = Physics.Raycast(_gazeOrigin,
                              _gazeDirection,
                              out hitInfo,
                              GazeMaxDistance);
        HitInfo = hitInfo;

        // Check whether raycast has hit.
        if (Hit == true)
        {
            Position = hitInfo.point;
            Normal   = hitInfo.normal;

            // Check whether the hit has a collider.
            if (hitInfo.collider != null)
            {
                // Set the focused object with what the user just looked at.
                FocusedObject = hitInfo.collider.gameObject;
            }
            else
            {
                // Object looked on is not valid, set focused gameobject to null.
                FocusedObject = null;
            }
        }
        else
        {
            // No object looked upon, set focused gameobject to null.
            FocusedObject = null;

            // Provide default position for cursor.
            Position = _gazeOrigin + (_gazeDirection * GazeMaxDistance);

            // Provide a default normal.
            Normal = _gazeDirection;
        }

        // Lerp the cursor to the given position, which helps to stabilize the gaze.
        Cursor.transform.position = Vector3.Lerp(Cursor.transform.position, Position, 0.6f);

        // Check whether the previous focused object is this same. If so, reset the focused object.
        if (FocusedObject != oldFocusedObject)
        {
            ResetFocusedObject();
            if (FocusedObject != null)
            {
                if (FocusedObject.CompareTag(InteractibleTag))
                {
                    // Provide the 'Gaze Entered' event.
                    FocusedObject.SendMessage("OnGazeEntered",
                                              SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }