private void Update()
        {
            Ray ray = (Cursor.lockState == CursorLockMode.Locked? new Ray(this.m_Transform.position, this.m_Transform.forward) : Camera.main.ScreenPointToRay(Input.mousePosition));

            RaycastHit hit;

            if (TriggerRaycaster.Raycast(ray, out hit, float.PositiveInfinity, this.m_LayerMask))
            {
                GameObject current = hit.collider.GetComponentInParent <BaseTrigger>().gameObject;

                if (m_LastCameraHit != current)
                {
                    if (this.m_LastCameraHit != null)
                    {
                        EventHandler.Execute(this.m_LastCameraHit, "OnPointerExitTrigger");
                    }

                    m_LastCameraHit = current;
                    EventHandler.Execute(m_LastCameraHit, "OnPointerEnterTrigger");
                }
                int button = -1;
                if (Input.GetMouseButtonDown(0))
                {
                    button = 0;
                }
                if (Input.GetMouseButtonDown(1))
                {
                    button = 1;
                }
                if (Input.GetMouseButtonDown(2))
                {
                    button = 2;
                }

                if (button != -1)
                {
                    m_LastCameraHit = current;
                    EventHandler.Execute <int>(m_LastCameraHit, "OnPoinerClickTrigger", button);
                }

                TriggerRaycaster.m_PointerOverTrigger = true;
            }
            else
            {
                if (m_LastCameraHit != null)
                {
                    EventHandler.Execute(m_LastCameraHit, "OnPointerExitTrigger");
                    m_LastCameraHit = null;
                }
                TriggerRaycaster.m_PointerOverTrigger = false;
            }
        }
예제 #2
0
        private void Update()
        {
            Ray ray = (Cursor.lockState == CursorLockMode.Locked? new Ray(this.m_Transform.position, this.m_Transform.forward) : Camera.main.ScreenPointToRay(Input.mousePosition));

            RaycastHit hit;

            if (TriggerRaycaster.Raycast(ray, out hit, float.PositiveInfinity, this.m_LayerMask))
            {
                if (m_LastCameraHit != hit.collider.gameObject)
                {
                    if (this.m_LastCameraHit != null)
                    {
                        EventHandler.Execute(this.m_LastCameraHit, "OnPointerExitTrigger");
                    }

                    m_LastCameraHit = hit.collider.gameObject;
                    EventHandler.Execute(m_LastCameraHit, "OnPointerEnterTrigger");
                }
                int button = -1;
                if (Input.GetMouseButtonDown(0))
                {
                    button = 0;
                }
                if (Input.GetMouseButtonDown(1))
                {
                    button = 1;
                }
                if (Input.GetMouseButtonDown(2))
                {
                    button = 2;
                }

                if (button != -1)
                {
                    m_LastCameraHit = hit.collider.gameObject;
                    EventHandler.Execute <int>(m_LastCameraHit, "OnPoinerClickTrigger", button);
                }

                TriggerRaycaster.m_PointerOverTrigger = true;
            }
            else
            {
                if (m_LastCameraHit != null)
                {
                    EventHandler.Execute(m_LastCameraHit, "OnPointerExitTrigger");
                    m_LastCameraHit = null;
                }
                TriggerRaycaster.m_PointerOverTrigger = false;
            }



            /*if (!UnityTools.IsPointerOverUI())
             * {
             *
             * /*  RaycastHit hit;
             * if (Physics.Raycast(this.m_Transform.position, this.m_Transform.forward, out hit, float.PositiveInfinity, this.m_LayerMask, QueryTriggerInteraction.Ignore))
             * {
             *    if (m_LastCameraHit != null && m_LastCameraHit != hit.collider.gameObject)
             *    {
             *        EventHandler.Execute<bool>(this.m_LastCameraHit, "OnCameraRaycast", false);
             *    }
             *    m_LastCameraHit = hit.collider.gameObject;
             *    EventHandler.Execute<bool>(m_LastCameraHit, "OnCameraRaycast", true);
             * }
             * else
             * {
             *    if (m_LastCameraHit != null)
             *    {
             *        EventHandler.Execute<bool>(m_LastCameraHit, "OnCameraRaycast", false);
             *        m_LastCameraHit = null;
             *    }
             * }
             *
             * if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, float.PositiveInfinity, this.m_LayerMask, QueryTriggerInteraction.Ignore))
             * {
             *    if (m_LastMouseHit != null && m_LastMouseHit != hit.collider.gameObject)
             *    {
             *        EventHandler.Execute<bool>(this.m_LastMouseHit, "OnMouseRaycast", false);
             *    }
             *    m_LastMouseHit = hit.collider.gameObject;
             *    EventHandler.Execute<bool>(m_LastMouseHit, "OnMouseRaycast", true);
             * }
             * else
             * {
             *    if (m_LastMouseHit != null)
             *    {
             *        EventHandler.Execute<bool>(m_LastMouseHit, "OnMouseRaycast", false);
             *        m_LastMouseHit = null;
             *    }
             * }*/
        }