Exemple #1
0
        static bool DoDispatch(BaseVisualElementPanel panel)
        {
            bool usesEvent;

            if (s_EventInstance.type == EventType.Repaint)
            {
                panel.Repaint(s_EventInstance);

                // TODO get rid of this when we wrap every GUIView inside IMGUIContainers
                // here we pretend to use the repaint event
                // in order to suspend to suspend OnGUI() processing on the native side
                // since we've already run it if we have an IMGUIContainer
                usesEvent = panel.IMGUIContainersCount > 0;
            }
            else
            {
                panel.ValidateLayout();

                using (EventBase evt = CreateEvent(s_EventInstance))
                {
                    bool immediate = s_EventInstance.type == EventType.Used || s_EventInstance.type == EventType.Layout || s_EventInstance.type == EventType.ExecuteCommand || s_EventInstance.type == EventType.ValidateCommand;
                    panel.SendEvent(evt, immediate ? DispatchMode.Immediate : DispatchMode.Queued);

                    // FIXME: we dont always have to repaint if evt.isPropagationStopped.
                    if (evt.isPropagationStopped)
                    {
                        panel.visualTree.IncrementVersion(VersionChangeType.Repaint);
                    }
                    usesEvent = evt.isPropagationStopped;
                }
            }

            return(usesEvent);
        }
        static bool DoDispatch(BaseVisualElementPanel panel)
        {
            Debug.Assert(panel.contextType == ContextType.Editor);

            bool usesEvent = false;

            if (s_EventInstance.type == EventType.Repaint)
            {
                var oldCam = Camera.current;
                var oldRT  = RenderTexture.active;

                Camera.SetupCurrent(null);
                RenderTexture.active = null;

                using (s_RepaintProfilerMarker.Auto())
                    panel.Repaint(s_EventInstance);

                (panel.panelDebug?.debuggerOverlayPanel as Panel)?.Repaint(s_EventInstance);
                // TODO get rid of this when we wrap every GUIView inside IMGUIContainers
                // here we pretend to use the repaint event
                // in order to suspend to suspend OnGUI() processing on the native side
                // since we've already run it if we have an IMGUIContainer
                usesEvent = panel.IMGUIContainersCount > 0;

                Camera.SetupCurrent(oldCam);
                RenderTexture.active = oldRT;
            }
            else
            {
                panel.ValidateLayout();

                using (EventBase evt = CreateEvent(s_EventInstance))
                {
                    bool immediate = s_EventInstance.type == EventType.Used || s_EventInstance.type == EventType.Layout || s_EventInstance.type == EventType.ExecuteCommand || s_EventInstance.type == EventType.ValidateCommand;

                    using (s_EventProfilerMarker.Auto())
                        panel.SendEvent(evt, immediate ? DispatchMode.Immediate : DispatchMode.Queued);

                    // The dispatcher should have finished processing the event,
                    // otherwise we cannot return a value for usesEvent.
                    // FIXME: this makes GUIPointWindowConversionOnMultipleWindow fails because the event sent in the OnGUI is put in the queue.
                    // Debug.Assert(evt.processed);

                    // FIXME: we dont always have to repaint if evt.isPropagationStopped.
                    if (evt.isPropagationStopped)
                    {
                        panel.visualTree.IncrementVersion(VersionChangeType.Repaint);
                        usesEvent = true;
                    }
                }
            }

            return(usesEvent);
        }
Exemple #3
0
        private static bool DoDispatch(BaseVisualElementPanel panel)
        {
            bool result = false;
            bool flag   = UIElementsUtility.s_EventInstance.type == EventType.Repaint;

            if (flag)
            {
                using (UIElementsUtility.s_RepaintProfilerMarker.Auto())
                {
                    panel.Repaint(UIElementsUtility.s_EventInstance);
                }
                IPanelDebug expr_46 = panel.panelDebug;
                Panel       expr_57 = ((expr_46 != null) ? expr_46.debuggerOverlayPanel : null) as Panel;
                if (expr_57 != null)
                {
                    expr_57.Repaint(UIElementsUtility.s_EventInstance);
                }
                result = (panel.IMGUIContainersCount > 0);
            }
            else
            {
                panel.ValidateLayout();
                using (EventBase eventBase = UIElementsUtility.CreateEvent(UIElementsUtility.s_EventInstance))
                {
                    bool flag2 = UIElementsUtility.s_EventInstance.type == EventType.Used || UIElementsUtility.s_EventInstance.type == EventType.Layout || UIElementsUtility.s_EventInstance.type == EventType.ExecuteCommand || UIElementsUtility.s_EventInstance.type == EventType.ValidateCommand;
                    using (UIElementsUtility.s_EventProfilerMarker.Auto())
                    {
                        panel.SendEvent(eventBase, flag2 ? DispatchMode.Immediate : DispatchMode.Default);
                    }
                    bool isPropagationStopped = eventBase.isPropagationStopped;
                    if (isPropagationStopped)
                    {
                        panel.visualTree.IncrementVersion(VersionChangeType.Repaint);
                        result = true;
                    }
                }
            }
            return(result);
        }