Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
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;
                    }
                }
            }
        }
Exemplo n.º 3
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;
                    }
                }
            }
        }