Ejemplo n.º 1
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; i++)
            {
                SendMouseEvents.m_CurrentHit[i] = default(SendMouseEvents.HitInfo);
            }
            if (!SendMouseEvents.s_MouseUsed)
            {
                Camera[] cameras = SendMouseEvents.m_Cameras;
                for (int j = 0; j < cameras.Length; j++)
                {
                    Camera camera = cameras[j];
                    if (!(camera == null) && (skipRTCameras == 0 || !(camera.targetTexture != null)))
                    {
                        if (camera.pixelRect.Contains(mousePosition))
                        {
                            GUILayer component = camera.GetComponent <GUILayer>();
                            if (component)
                            {
                                GUIElement gUIElement = component.HitTest(mousePosition);
                                if (gUIElement)
                                {
                                    SendMouseEvents.m_CurrentHit[0].target = gUIElement.gameObject;
                                    SendMouseEvents.m_CurrentHit[0].camera = camera;
                                }
                                else
                                {
                                    SendMouseEvents.m_CurrentHit[0].target = null;
                                    SendMouseEvents.m_CurrentHit[0].camera = null;
                                }
                            }
                            if (camera.eventMask != 0)
                            {
                                Ray        ray        = camera.ScreenPointToRay(mousePosition);
                                float      z          = ray.direction.z;
                                float      distance   = (!Mathf.Approximately(0f, z)) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                                GameObject gameObject = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                                if (gameObject != null)
                                {
                                    SendMouseEvents.m_CurrentHit[1].target = gameObject;
                                    SendMouseEvents.m_CurrentHit[1].camera = camera;
                                }
                                else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                                {
                                    SendMouseEvents.m_CurrentHit[1].target = null;
                                    SendMouseEvents.m_CurrentHit[1].camera = null;
                                }
                                GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                                if (gameObject2 != null)
                                {
                                    SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                    SendMouseEvents.m_CurrentHit[2].camera = camera;
                                }
                                else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                                {
                                    SendMouseEvents.m_CurrentHit[2].target = null;
                                    SendMouseEvents.m_CurrentHit[2].camera = null;
                                }
                            }
                        }
                    }
                }
            }
            for (int k = 0; k < SendMouseEvents.m_CurrentHit.Length; k++)
            {
                SendMouseEvents.SendEvents(k, SendMouseEvents.m_CurrentHit[k]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
Ejemplo n.º 2
0
 public static bool Compare(SendMouseEvents.HitInfo lhs, SendMouseEvents.HitInfo rhs)
 {
     return ((lhs.target == rhs.target) && (lhs.camera == rhs.camera));
 }
Ejemplo n.º 3
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int index = 0; index < SendMouseEvents.m_CurrentHit.Length; ++index)
            {
                SendMouseEvents.m_CurrentHit[index] = new SendMouseEvents.HitInfo();
            }
            if (!SendMouseEvents.s_MouseUsed)
            {
                foreach (Camera camera in SendMouseEvents.m_Cameras)
                {
                    if (!((Object)camera == (Object)null) && (skipRTCameras == 0 || !((Object)camera.targetTexture != (Object)null)) && camera.pixelRect.Contains(mousePosition))
                    {
                        GUILayer component = camera.GetComponent <GUILayer>();
                        if ((bool)((Object)component))
                        {
                            GUIElement guiElement = component.HitTest(mousePosition);
                            if ((bool)((Object)guiElement))
                            {
                                SendMouseEvents.m_CurrentHit[0].target = guiElement.gameObject;
                                SendMouseEvents.m_CurrentHit[0].camera = camera;
                            }
                            else
                            {
                                SendMouseEvents.m_CurrentHit[0].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[0].camera = (Camera)null;
                            }
                        }
                        if (camera.eventMask != 0)
                        {
                            Ray        ray         = camera.ScreenPointToRay(mousePosition);
                            float      z           = ray.direction.z;
                            float      distance    = !Mathf.Approximately(0.0f, z) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                            GameObject gameObject1 = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                            if ((Object)gameObject1 != (Object)null)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = gameObject1;
                                SendMouseEvents.m_CurrentHit[1].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[1].camera = (Camera)null;
                            }
                            GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                            if ((Object)gameObject2 != (Object)null)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                SendMouseEvents.m_CurrentHit[2].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = (GameObject)null;
                                SendMouseEvents.m_CurrentHit[2].camera = (Camera)null;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; ++i)
            {
                SendMouseEvents.SendEvents(i, SendMouseEvents.m_CurrentHit[i]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
Ejemplo n.º 4
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;

            if (SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; i++)
            {
                SendMouseEvents.m_CurrentHit[i] = default(SendMouseEvents.HitInfo);
            }
            if (!SendMouseEvents.s_MouseUsed)
            {
                foreach (Camera camera in SendMouseEvents.m_Cameras)
                {
                    if (!(camera == null) && (skipRTCameras == 0 || !(camera.targetTexture != null)))
                    {
                        int     targetDisplay = camera.targetDisplay;
                        Vector3 vector        = Display.RelativeMouseAt(mousePosition);
                        if (vector != Vector3.zero)
                        {
                            int num = (int)vector.z;
                            if (num != targetDisplay)
                            {
                                goto IL_361;
                            }
                            float num2 = (float)Screen.width;
                            float num3 = (float)Screen.height;
                            if (targetDisplay > 0 && targetDisplay < Display.displays.Length)
                            {
                                num2 = (float)Display.displays[targetDisplay].systemWidth;
                                num3 = (float)Display.displays[targetDisplay].systemHeight;
                            }
                            Vector2 vector2 = new Vector2(vector.x / num2, vector.y / num3);
                            if (vector2.x < 0f || vector2.x > 1f || vector2.y < 0f || vector2.y > 1f)
                            {
                                goto IL_361;
                            }
                        }
                        else
                        {
                            vector = mousePosition;
                            if (!camera.pixelRect.Contains(vector))
                            {
                                goto IL_361;
                            }
                        }
                        SendMouseEvents.HitTestLegacyGUI(camera, vector, ref SendMouseEvents.m_CurrentHit[0]);
                        if (camera.eventMask != 0)
                        {
                            Ray        ray        = camera.ScreenPointToRay(vector);
                            float      z          = ray.direction.z;
                            float      distance   = (!Mathf.Approximately(0f, z)) ? Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z) : float.PositiveInfinity;
                            GameObject gameObject = camera.RaycastTry(ray, distance, camera.cullingMask & camera.eventMask);
                            if (gameObject != null)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = gameObject;
                                SendMouseEvents.m_CurrentHit[1].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[1].target = null;
                                SendMouseEvents.m_CurrentHit[1].camera = null;
                            }
                            GameObject gameObject2 = camera.RaycastTry2D(ray, distance, camera.cullingMask & camera.eventMask);
                            if (gameObject2 != null)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                SendMouseEvents.m_CurrentHit[2].camera = camera;
                            }
                            else if (camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color)
                            {
                                SendMouseEvents.m_CurrentHit[2].target = null;
                                SendMouseEvents.m_CurrentHit[2].camera = null;
                            }
                        }
                    }
                    IL_361 :;
                }
            }
            for (int k = 0; k < SendMouseEvents.m_CurrentHit.Length; k++)
            {
                SendMouseEvents.SendEvents(k, SendMouseEvents.m_CurrentHit[k]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
Ejemplo n.º 5
0
        private static void DoSendMouseEvents(int skipRTCameras)
        {
            Vector3 mousePosition   = Input.mousePosition;
            int     allCamerasCount = Camera.allCamerasCount;
            bool    flag            = SendMouseEvents.m_Cameras == null || SendMouseEvents.m_Cameras.Length != allCamerasCount;

            if (flag)
            {
                SendMouseEvents.m_Cameras = new Camera[allCamerasCount];
            }
            Camera.GetAllCameras(SendMouseEvents.m_Cameras);
            for (int i = 0; i < SendMouseEvents.m_CurrentHit.Length; i++)
            {
                SendMouseEvents.m_CurrentHit[i] = default(SendMouseEvents.HitInfo);
            }
            bool flag2 = !SendMouseEvents.s_MouseUsed;

            if (flag2)
            {
                Camera[] cameras = SendMouseEvents.m_Cameras;
                for (int j = 0; j < cameras.Length; j++)
                {
                    Camera camera = cameras[j];
                    bool   flag3  = camera == null || (skipRTCameras != 0 && camera.targetTexture != null);
                    if (!flag3)
                    {
                        int     targetDisplay = camera.targetDisplay;
                        Vector3 vector        = Display.RelativeMouseAt(mousePosition);
                        bool    flag4         = vector != Vector3.zero;
                        if (flag4)
                        {
                            int  num   = (int)vector.z;
                            bool flag5 = num != targetDisplay;
                            if (flag5)
                            {
                                goto IL_358;
                            }
                            float num2  = (float)Screen.width;
                            float num3  = (float)Screen.height;
                            bool  flag6 = targetDisplay > 0 && targetDisplay < Display.displays.Length;
                            if (flag6)
                            {
                                num2 = (float)Display.displays[targetDisplay].systemWidth;
                                num3 = (float)Display.displays[targetDisplay].systemHeight;
                            }
                            Vector2 vector2 = new Vector2(vector.x / num2, vector.y / num3);
                            bool    flag7   = vector2.x <0f || vector2.x> 1f || vector2.y <0f || vector2.y> 1f;
                            if (flag7)
                            {
                                goto IL_358;
                            }
                        }
                        else
                        {
                            vector = mousePosition;
                        }
                        bool flag8 = !camera.pixelRect.Contains(vector);
                        if (!flag8)
                        {
                            bool flag9 = camera.eventMask == 0;
                            if (!flag9)
                            {
                                Ray        ray        = camera.ScreenPointToRay(vector);
                                float      z          = ray.direction.z;
                                float      distance   = Mathf.Approximately(0f, z) ? float.PositiveInfinity : Mathf.Abs((camera.farClipPlane - camera.nearClipPlane) / z);
                                GameObject gameObject = CameraRaycastHelper.RaycastTry(camera, ray, distance, camera.cullingMask & camera.eventMask);
                                bool       flag10     = gameObject != null;
                                if (flag10)
                                {
                                    SendMouseEvents.m_CurrentHit[1].target = gameObject;
                                    SendMouseEvents.m_CurrentHit[1].camera = camera;
                                }
                                else
                                {
                                    bool flag11 = camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color;
                                    if (flag11)
                                    {
                                        SendMouseEvents.m_CurrentHit[1].target = null;
                                        SendMouseEvents.m_CurrentHit[1].camera = null;
                                    }
                                }
                                GameObject gameObject2 = CameraRaycastHelper.RaycastTry2D(camera, ray, distance, camera.cullingMask & camera.eventMask);
                                bool       flag12      = gameObject2 != null;
                                if (flag12)
                                {
                                    SendMouseEvents.m_CurrentHit[2].target = gameObject2;
                                    SendMouseEvents.m_CurrentHit[2].camera = camera;
                                }
                                else
                                {
                                    bool flag13 = camera.clearFlags == CameraClearFlags.Skybox || camera.clearFlags == CameraClearFlags.Color;
                                    if (flag13)
                                    {
                                        SendMouseEvents.m_CurrentHit[2].target = null;
                                        SendMouseEvents.m_CurrentHit[2].camera = null;
                                    }
                                }
                            }
                        }
                    }
                    IL_358 :;
                }
            }
            for (int k = 0; k < SendMouseEvents.m_CurrentHit.Length; k++)
            {
                SendMouseEvents.SendEvents(k, SendMouseEvents.m_CurrentHit[k]);
            }
            SendMouseEvents.s_MouseUsed = false;
        }
 private static void SendEvents(int i, SendMouseEvents.HitInfo hit)
 {
   bool mouseButtonDown = Input.GetMouseButtonDown(0);
   bool mouseButton = Input.GetMouseButton(0);
   if (mouseButtonDown)
   {
     if ((bool) hit)
     {
       SendMouseEvents.m_MouseDownHit[i] = hit;
       SendMouseEvents.m_MouseDownHit[i].SendMessage("OnMouseDown");
     }
   }
   else if (!mouseButton)
   {
     if ((bool) SendMouseEvents.m_MouseDownHit[i])
     {
       if (SendMouseEvents.HitInfo.Compare(hit, SendMouseEvents.m_MouseDownHit[i]))
         SendMouseEvents.m_MouseDownHit[i].SendMessage("OnMouseUpAsButton");
       SendMouseEvents.m_MouseDownHit[i].SendMessage("OnMouseUp");
       SendMouseEvents.m_MouseDownHit[i] = new SendMouseEvents.HitInfo();
     }
   }
   else if ((bool) SendMouseEvents.m_MouseDownHit[i])
     SendMouseEvents.m_MouseDownHit[i].SendMessage("OnMouseDrag");
   if (SendMouseEvents.HitInfo.Compare(hit, SendMouseEvents.m_LastHit[i]))
   {
     if ((bool) hit)
       hit.SendMessage("OnMouseOver");
   }
   else
   {
     if ((bool) SendMouseEvents.m_LastHit[i])
       SendMouseEvents.m_LastHit[i].SendMessage("OnMouseExit");
     if ((bool) hit)
     {
       hit.SendMessage("OnMouseEnter");
       hit.SendMessage("OnMouseOver");
     }
   }
   SendMouseEvents.m_LastHit[i] = hit;
 }
 public static bool Compare(SendMouseEvents.HitInfo lhs, SendMouseEvents.HitInfo rhs)
 {
   if ((Object) lhs.target == (Object) rhs.target)
     return (Object) lhs.camera == (Object) rhs.camera;
   return false;
 }
Ejemplo n.º 8
0
			public static bool Compare(SendMouseEvents.HitInfo lhs, SendMouseEvents.HitInfo rhs)
			{
				return lhs.target == rhs.target && lhs.camera == rhs.camera;
			}