示例#1
0
    private void OnGUI()
    {
        try
        {
            inOnGUI   = true;
            GUI.depth = 0x31;
            blankID   = GUIUtility.GetControlID(FocusType.Keyboard);
            GUI.SetNextControlName("ngui-unityevents");
            controlID = GUIUtility.GetControlID(FocusType.Keyboard);
            GUI.color = Color.clear;
            Event     current = Event.current;
            EventType type    = current.type;
            if (type == EventType.MouseMove)
            {
                Debug.Log("Mouse Move");
            }
            switch (type)
            {
            case EventType.MouseDown:
                if (!forbidHandlingNewEvents)
                {
                    bool flag = current.button == 0;
                    using (Event event6 = new Event(current))
                    {
                        UICamera.HandleEvent(event6, type);
                    }
                    if ((flag && (current.type == EventType.Used)) && (GUIUtility.hotControl == 0))
                    {
                        GUIUtility.hotControl = blankID;
                    }
                }
                break;

            case EventType.MouseUp:
            {
                bool flag2 = current.button == 0;
                using (Event event7 = new Event(current))
                {
                    UICamera.HandleEvent(event7, type);
                }
                if (flag2 && (GUIUtility.hotControl == blankID))
                {
                    GUIUtility.hotControl = 0;
                }
                break;
            }

            case EventType.MouseMove:
            case EventType.MouseDrag:
            case EventType.KeyUp:
            case EventType.ScrollWheel:
                using (Event event4 = new Event(current))
                {
                    UICamera.HandleEvent(event4, type);
                }
                break;

            case EventType.KeyDown:
                if (!forbidHandlingNewEvents)
                {
                    using (Event event5 = new Event(current))
                    {
                        UICamera.HandleEvent(event5, type);
                    }
                }
                break;

            case EventType.Repaint:
                if (!forbidHandlingNewEvents && (lastMousePosition != current.mousePosition))
                {
                    lastMousePosition = current.mousePosition;
                    using (Event event3 = new Event(current, EventType.MouseMove))
                    {
                        UICamera.HandleEvent(event3, EventType.MouseMove);
                    }
                }
                break;

            case EventType.Used:
                Debug.Log("Used");
                return;
            }
            if (type == EventType.Repaint)
            {
            }
        }
        finally
        {
            inOnGUI = false;
        }
    }
示例#2
0
    private void OnGUI()
    {
        try
        {
            UIUnityEvents.inOnGUI = true;
            GUI.depth             = 49;
            UIUnityEvents.blankID = GUIUtility.GetControlID(FocusType.Keyboard);
            GUI.SetNextControlName("ngui-unityevents");
            UIUnityEvents.controlID = GUIUtility.GetControlID(FocusType.Keyboard);
            GUI.color = Color.clear;
            UnityEngine.Event @event    = UnityEngine.Event.current;
            EventType         eventType = @event.type;
            if (eventType == EventType.MouseMove)
            {
                Debug.Log("Mouse Move");
            }
            switch (eventType)
            {
            case EventType.MouseDown:
            {
                if (!UIUnityEvents.forbidHandlingNewEvents)
                {
                    bool flag = @event.button == 0;
                    using (NGUIHack.Event event1 = new NGUIHack.Event(@event))
                    {
                        UICamera.HandleEvent(event1, eventType);
                    }
                    if (flag && @event.type == EventType.Used && GUIUtility.hotControl == 0)
                    {
                        GUIUtility.hotControl = UIUnityEvents.blankID;
                    }
                }
                goto case EventType.DragPerform;
            }

            case EventType.MouseUp:
            {
                bool flag1 = @event.button == 0;
                using (NGUIHack.Event event2 = new NGUIHack.Event(@event))
                {
                    UICamera.HandleEvent(event2, eventType);
                }
                if (flag1 && GUIUtility.hotControl == UIUnityEvents.blankID)
                {
                    GUIUtility.hotControl = 0;
                }
                goto case EventType.DragPerform;
            }

            case EventType.MouseMove:
            case EventType.MouseDrag:
            case EventType.KeyUp:
            case EventType.ScrollWheel:
            {
                using (NGUIHack.Event event3 = new NGUIHack.Event(@event))
                {
                    UICamera.HandleEvent(event3, eventType);
                }
                goto case EventType.DragPerform;
            }

            case EventType.KeyDown:
            {
                if (!UIUnityEvents.forbidHandlingNewEvents)
                {
                    using (NGUIHack.Event event4 = new NGUIHack.Event(@event))
                    {
                        UICamera.HandleEvent(event4, eventType);
                    }
                }
                goto case EventType.DragPerform;
            }

            case EventType.Repaint:
            {
                if (!UIUnityEvents.forbidHandlingNewEvents && UIUnityEvents.lastMousePosition != @event.mousePosition)
                {
                    UIUnityEvents.lastMousePosition = @event.mousePosition;
                    using (NGUIHack.Event event5 = new NGUIHack.Event(@event, EventType.MouseMove))
                    {
                        UICamera.HandleEvent(event5, EventType.MouseMove);
                    }
                }
                goto case EventType.DragPerform;
            }

            case EventType.DragUpdated:
            case EventType.DragPerform:
            {
Label0:
                eventType != EventType.Repaint;
                break;
            }

            case EventType.Used:
            {
                Debug.Log("Used");
                break;
            }

            default:
            {
                goto case EventType.DragPerform;
            }
            }
        }
        finally
        {
            UIUnityEvents.inOnGUI = false;
        }
    }