public static VisualElement GetVisualTree(GUIViewProxy guiViewProxy)
        {
#if UNITY_2020_1_OR_NEWER
            return(EditorWindowBackendManager.GetBackend(guiViewProxy.guiView).visualTree as VisualElement);
#else
            return((VisualElement)s_VisualTreeProperty.GetValue(guiViewProxy.guiView, new object[0]));
#endif
        }
        public static VisualElement GetVisualTree(GUIViewProxy guiViewProxy)
        {
            return((VisualElement)s_VisualTreeProperty.GetValue(
#if UNITY_2020_1_OR_NEWER
                       guiViewProxy.guiView.windowBackend,
#else
                       guiViewProxy.guiView,
#endif
                       new object[0]
                       ));
        }
Beispiel #3
0
        internal static bool IsHighlighted(GUIViewProxy view, List <Rect> rects)
        {
            rects.Clear();
            MaskViewData maskViewData;

            if (!s_HighlightedViews.TryGetValue(view, out maskViewData))
            {
                return(false);
            }
            var rectList = maskViewData.rects;

            rects.AddRange(rectList);
            return(true);
        }
 public static void Add(GUIViewProxy view, VisualElement child)
 {
     if (view.IsDockedToEditor())
     {
         Add(GetVisualTree(view), child);
     }
     else
     {
         foreach (var visualElement in GetVisualTree(view).Children())
         {
             Add(visualElement, child);
         }
     }
 }
        internal static UnmaskedView CreateInstanceForGUIView <T>(IList <GUIControlSelector> unmaskedControls = null)
        {
            if (!GUIViewProxy.IsAssignableFrom(typeof(T)))
            {
                throw new InvalidOperationException("Type must be assignable to GUIView");
            }

            UnmaskedView result = new UnmaskedView();

            result.m_SelectorType  = SelectorType.GUIView;
            result.m_ViewType.type = typeof(T);
            if (unmaskedControls != null)
            {
                result.m_UnmaskedControls.AddRange(unmaskedControls);
            }
            return(result);
        }
        internal static bool IsMasked(GUIViewProxy view, List <Rect> rects)
        {
            rects.Clear();

            var unmaskedViewsKeys = s_UnmaskedViews.Keys.ToList();

            Debug.Log(unmaskedViewsKeys.Count);
            MaskViewData maskViewData;

            if (s_UnmaskedViews.TryGetValue(view, out maskViewData))
            {
                var rectList = maskViewData.rects;
                rects.AddRange(rectList);
                return(false);
            }
            return(true);
        }
Beispiel #7
0
        public static void AddMaskToView(GUIViewProxy view, VisualElement child)
        {
            // Since 2019.3(?), we must suppress input to the elements behind masks.
            // TODO Doesn't suppress everything, e.g. tooltips are shown still.
            child.RegisterCallback <MouseDownEvent>((e) => e.StopPropagation());
            child.RegisterCallback <MouseUpEvent>((e) => e.StopPropagation());
            child.RegisterCallback <MouseMoveEvent>((e) => e.StopPropagation());
            child.RegisterCallback <WheelEvent>((e) => e.StopPropagation());
            child.RegisterCallback <PointerDownEvent>((e) => e.StopPropagation());
            child.RegisterCallback <PointerUpEvent>((e) => e.StopPropagation());
            child.RegisterCallback <PointerMoveEvent>((e) => e.StopPropagation());
            child.RegisterCallback <KeyDownEvent>((e) => e.StopPropagation());
            child.RegisterCallback <KeyUpEvent>((e) => e.StopPropagation());

            if (view.IsDockedToEditor())
            {
                UIElementsHelper.Add(UIElementsHelper.GetVisualTree(view), child);
            }
            else
            {
                var viewVisualElement = UIElementsHelper.GetVisualTree(view);

                Debug.Assert(
                    viewVisualElement.Children().Count() == 2 &&
                    viewVisualElement.Children().Count(viewChild => viewChild is IMGUIContainer) == 1,
                    "Could not find the expected VisualElement structure"
                    );

                foreach (var visualElement in viewVisualElement.Children())
                {
                    if (!(visualElement is IMGUIContainer))
                    {
                        UIElementsHelper.Add(visualElement, child);
                        break;
                    }
                }
            }
        }
Beispiel #8
0
        public static void AddMaskToView(GUIViewProxy view, VisualElement child)
        {
            if (view.IsDockedToEditor())
            {
                UIElementsHelper.Add(UIElementsHelper.GetVisualTree(view), child);
            }
            else
            {
                var viewVisualElement = UIElementsHelper.GetVisualTree(view);

                Debug.Assert(viewVisualElement.Children().Count() == 2 &&
                             viewVisualElement.Children().Count(viewChild => viewChild is IMGUIContainer) == 1,
                             "Could not find the expected VisualElement structure");

                foreach (var visualElement in viewVisualElement.Children())
                {
                    if (!(visualElement is IMGUIContainer))
                    {
                        UIElementsHelper.Add(visualElement, child);
                        break;
                    }
                }
            }
        }
Beispiel #9
0
 public static VisualElement GetVisualTree(GUIViewProxy guiViewProxy)
 {
     return((VisualElement)s_VisualTreeProperty.GetValue(guiViewProxy.guiView, new object[0]));
 }
 public static void DebugWindow(GUIViewProxy guiViewProxy)
 {
     GUIViewDebuggerHelper.DebugWindow(guiViewProxy.guiView);
 }