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]
                       ));
        }
Exemple #2
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())
     {
         GetVisualTree(view).Add(child);
     }
     else
     {
         foreach (var visualElement in GetVisualTree(view).Children())
         {
             visualElement.Add(child);
         }
     }
 }
        internal static UnmaskedView CreateInstanceForGUIView(Type type, IList <GuiControlSelector> unmaskedControls = null)
        {
            if (!GUIViewProxy.IsAssignableFrom(type))
            {
                throw new InvalidOperationException("Type must be assignable to GUIView");
            }

            UnmaskedView result = new UnmaskedView();

            result.m_SelectorType  = SelectorType.GUIView;
            result.m_ViewType.Type = type;
            if (unmaskedControls != null)
            {
                result.m_UnmaskedControls.AddRange(unmaskedControls);
            }
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Adds a mask for a view.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="child"></param>
        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.GetVisualTree(view).Add(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))
                    {
                        visualElement.Add(child);
                        break;
                    }
                }
            }
        }
        void BeginPicking(SerializedProperty property)
        {
            // Look through all Editor Windows and GUIViews
            registeredWindows     = Resources.FindObjectsOfTypeAll <EditorWindow>().ToList();
            guiViewVisualElements = GUIViewProxy.FindAllGuiViewVisualElements();
            pickerCallback        = (evt) => PickCurrentHoveredElement(evt.target as VisualElement, evt, property);

            foreach (var targetWindow in registeredWindows)
            {
                if (targetWindow != null)
                {
                    targetWindow.rootVisualElement.RegisterCallback(pickerCallback, TrickleDown.TrickleDown);
                }
            }

            foreach (var targetVis in guiViewVisualElements)
            {
                if (targetVis != null)
                {
                    targetVis.RegisterCallback(pickerCallback, TrickleDown.TrickleDown);
                }
            }
        }
Exemple #7
0
 public static VisualElement GetVisualTree(GUIViewProxy guiViewProxy) => GetVisualTree(guiViewProxy.GuiView);
 public static void DebugWindow(GUIViewProxy guiViewProxy)
 {
     GUIViewDebuggerHelper.DebugWindow(guiViewProxy.GuiView);
 }