Show() public static method

public static Show ( Rect activatorRect, PopupWindowContent windowContent ) : void
activatorRect UnityEngine.Rect
windowContent PopupWindowContent
return void
示例#1
0
        // when current event is mouse click, this function pings the object, or
        // if shift/control is pressed and object is a texture, pops up a large texture
        // preview window
        internal static void PingObjectOrShowPreviewOnClick(Object targetObject, Rect position)
        {
            if (targetObject == null)
            {
                return;
            }

            Event evt = Event.current;
            // ping object
            bool anyModifiersPressed = evt.shift || evt.control;

            if (!anyModifiersPressed)
            {
                EditorGUIUtility.PingObject(targetObject);
                return;
            }

            // show large object preview popup; right now only for textures
            if (targetObject is Texture)
            {
                PopupWindowWithoutFocus.Show(
                    new RectOffset(6, 3, 0, 3).Add(position),
                    new ObjectPreviewPopup(targetObject),
                    new[] { PopupLocation.Left, PopupLocation.Below, PopupLocation.Right });
            }
        }
示例#2
0
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem importPackageItem = pitem.item;

                if (importPackageItem == null)
                {
                    return;
                }
                if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                {
                    this.showPreviewForID = pitem.id;
                }
                if (pitem.id != this.showPreviewForID || Event.current.type == EventType.Layout)
                {
                    return;
                }
                this.showPreviewForID = 0;
                if (string.IsNullOrEmpty(importPackageItem.previewPath))
                {
                    return;
                }
                Texture2D preview       = PackageImport.GetPreview(importPackageItem.previewPath);
                Rect      activatorRect = rowRect;

                activatorRect.width = EditorGUIUtility.currentViewWidth;
                PopupWindowWithoutFocus.Show(activatorRect, (PopupWindowContent) new PackageImportTreeView.PreviewPopup(preview), new PopupLocationHelper.PopupLocation[3]
                {
                    PopupLocationHelper.PopupLocation.Right,
                    PopupLocationHelper.PopupLocation.Left,
                    PopupLocationHelper.PopupLocation.Below
                });
            }
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    if (((Event.current.type == EventType.MouseDown) && rowRect.Contains(Event.current.mousePosition)) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = pitem.id;
                    }
                    if ((pitem.id == this.showPreviewForID) && (Event.current.type != EventType.Layout))
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview       = PackageImport.GetPreview(item.previewPath);
                            Rect      activatorRect = rowRect;
                            activatorRect.width = EditorGUIUtility.currentViewWidth;
                            PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3];
                            locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right;
                            locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder);
                        }
                    }
                }
            }
            void DoPreviewPopup(PackageImportTreeViewItem pitem, Rect rowRect)
            {
                var item = pitem.item;

                if (item != null)
                {
                    // Ensure preview is shown when clicking on an already selected item (the preview might have been closed)
                    if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        showPreviewForID = pitem.id;
                    }

                    // Show preview
                    if (pitem.id == showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview    = PackageImport.GetPreview(item.previewPath);
                            Rect      buttonRect = rowRect;
                            buttonRect.width = EditorGUIUtility.currentViewWidth;
                            PopupWindowWithoutFocus.Show(buttonRect, new PreviewPopup(preview), new[] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below });
                        }
                    }
                }
            }
示例#5
0
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = pitem.id;
                    }
                    if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview = PackageImport.GetPreview(item.previewPath);
                            Rect      rect    = rowRect;
                            rect.width = EditorGUIUtility.currentViewWidth;
                            Rect arg_AF_0 = rect;
                            PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview);
                            PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3];
                            expr_A7[0] = PopupLocationHelper.PopupLocation.Right;
                            expr_A7[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7);
                        }
                    }
                }
            }
        void DoPreviewPopup()
        {
            if (state.selectedIDs.Count != 1)
            {
                PopupWindowWithoutFocus.Hide();
                return;
            }

            var item = FindItem(state.selectedIDs[0], rootItem) as PrefabOverridesTreeViewItem;

            if (item == null || item.obj == null)
            {
                return;
            }

            if (PopupWindowWithoutFocus.IsVisible())
            {
                if (item.id == m_LastShownPreviewWindowRowID)
                {
                    return;
                }
            }

            int row = FindRowOfItem(item);

            if (row == -1)
            {
                return;
            }

            Rect buttonRect = GetRowRect(row);

            buttonRect.width = EditorGUIUtility.currentViewWidth;
            Object rowObject = item.obj;

            Object instance, source;

            if (item.type == ItemType.REMOVED_OBJECT)
            {
                instance = null;
                source   = rowObject;
            }
            else if (item.type == ItemType.ADDED_OBJECT)
            {
                instance = rowObject;
                source   = null;
            }
            else
            {
                instance = rowObject;
                source   = PrefabUtility.GetCorrespondingObjectFromSource(rowObject);
            }

            m_LastShownPreviewWindowRowID = item.id;
            PopupWindowWithoutFocus.Show(
                buttonRect,
                new ComparisonViewPopup(source, instance, item.singleModification, this),
                new[] { PopupLocation.Right, PopupLocation.Left, PopupLocation.Below });
        }
            public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
            {
                Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight);

                this.DoNodeGUI(rect, node, selected, focused, false);
                PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem;
                if (packageImportTreeViewItem != null)
                {
                    Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height);
                    EditorGUI.BeginChangeCheck();
                    PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id))
                        {
                            this.m_TreeView.SetSelection(new int[]
                            {
                                packageImportTreeViewItem.id
                            }, false);
                            this.m_TreeView.NotifyListenersThatSelectionChanged();
                        }
                        if (this.itemWasToggled != null)
                        {
                            this.itemWasToggled(packageImportTreeViewItem);
                        }
                        Event.current.Use();
                    }
                    if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = packageImportTreeViewItem.id;
                    }
                    if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath))
                        {
                            Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath);
                            Rect      rect2   = rect;
                            rect2.width = EditorGUIUtility.currentViewWidth;
                            Rect arg_190_0 = rect2;
                            PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview);
                            PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3];
                            expr_188[0] = PopupLocationHelper.PopupLocation.Right;
                            expr_188[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188);
                        }
                    }
                    if (packageImportTreeViewItem.item.exists == 0)
                    {
                        Texture image = this.constants.badgeNew.image;
                        GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image);
                    }
                }
                return(rect);
            }
        void DoPreviewPopup(PrefabOverridesTreeViewItem item, Rect rowRect)
        {
            if (item != null)
            {
                // Ensure preview is shown when clicking on an already selected item (the preview might have been closed)
                if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                {
                    m_ShowPreviewForID = item.id;
                }

                // Show preview
                if (item.id == m_ShowPreviewForID && Event.current.type != EventType.Layout)
                {
                    m_ShowPreviewForID = -1;
                    if (item.obj != null)
                    {
                        Rect buttonRect = rowRect;
                        buttonRect.width = EditorGUIUtility.currentViewWidth;
                        Object rowObject = item.obj;

                        Object instance, source;
                        if (item.type == ItemType.REMOVED_OBJECT)
                        {
                            instance = null;
                            source   = rowObject;
                        }
                        else if (item.type == ItemType.ADDED_OBJECT)
                        {
                            instance = rowObject;
                            source   = null;
                        }
                        else
                        {
                            instance = rowObject;
                            source   = PrefabUtility.GetCorrespondingObjectFromSource(rowObject);
                        }

                        PopupWindowWithoutFocus.Show(
                            buttonRect,
                            new ComparisonViewPopup(source, instance, item.singleModification, this),
                            new[] { PopupLocation.Right, PopupLocation.Left, PopupLocation.Below });
                    }
                }
            }
        }
        void DoPreviewPopup(PrefabOverridesTreeViewItem item, Rect rowRect)
        {
            if (item == null || item.obj == null)
            {
                return;
            }

            if (PopupWindowWithoutFocus.IsVisible())
            {
                if (item.id == m_LastShownPreviewWindowRowID)
                {
                    return;
                }
            }

            Rect buttonRect = rowRect;

            buttonRect.width = EditorGUIUtility.currentViewWidth;
            Object rowObject = item.obj;

            Object instance, source;

            if (item.type == ItemType.REMOVED_OBJECT)
            {
                instance = null;
                source   = rowObject;
            }
            else if (item.type == ItemType.ADDED_OBJECT)
            {
                instance = rowObject;
                source   = null;
            }
            else
            {
                instance = rowObject;
                source   = PrefabUtility.GetCorrespondingObjectFromSource(rowObject);
            }

            m_LastShownPreviewWindowRowID = item.id;
            PopupWindowWithoutFocus.Show(
                buttonRect,
                new ComparisonViewPopup(source, instance, item.singleModification, this),
                new[] { PopupLocation.Right, PopupLocation.Left, PopupLocation.Below });
        }
示例#10
0
        private void ShowKeywords(Shader s)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Keywords", EditorStyles.miniButton);

            Rect buttonRect = GUILayoutUtility.GetRect(Styles.arrayValuePopupButton, GUI.skin.button, GUILayout.MinWidth(kValueFieldWidth));

            buttonRect.width = kArrayValuePopupBtnWidth;
            if (GUI.Button(buttonRect, Styles.arrayValuePopupButton, EditorStyles.miniButton))
            {
                var globalKeywords = ShaderUtil.GetShaderGlobalKeywords(s);
                var localKeywords  = ShaderUtil.GetShaderLocalKeywords(s);

                PopupWindowWithoutFocus.Show(
                    buttonRect,
                    new KeywordsPopup(globalKeywords, localKeywords, 150.0f),
                    new[] { PopupLocation.Left, PopupLocation.Below, PopupLocation.Right });
            }

            EditorGUILayout.EndHorizontal();
        }
示例#11
0
        /// Make a field for a generic mask.
        /// This version also gives you back which flags were changed and what they were changed to.
        /// This is useful if you want to make the same change to multiple objects.
        internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, out int changedFlags, out bool changedToValue, Type enumType = null)
        {
            mask = MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue);

            GetMenuOptions(mask, flagNames, flagValues, out var buttonText, out var buttonTextMixed, out var optionNames, out var optionMaskValues, out var selectedOptions, enumType);

            Event evt = Event.current;

            if (evt.type == EventType.Repaint)
            {
                var buttonContent = EditorGUI.showMixedValue ? EditorGUI.mixedValueContent : DoMixedLabel(buttonText, buttonTextMixed, position, style);
                style.Draw(position, buttonContent, controlID, false, position.Contains(evt.mousePosition));
            }
            else if ((evt.type == EventType.MouseDown && position.Contains(evt.mousePosition)) || evt.MainActionKeyForControl(controlID))
            {
                MaskCallbackInfo.m_Instance = new MaskCallbackInfo(controlID);
                PopupWindowWithoutFocus.Show(position, new MaskFieldDropDown(optionNames, optionMaskValues, mask, MaskCallbackInfo.m_Instance.SetMaskValueDelegate));
            }

            return(mask);
        }
        void DrawUnusedOverridesButton()
        {
            Rect buttonRect = GUILayoutUtility.GetRect(100, 10000, k_NoOverridesLabelHeight, k_NoOverridesLabelHeight);

            if (Event.current.type == EventType.Repaint)
            {
                if (UnusedOverridesViewPopup.s_IsOpen)
                {
                    Styles.removeOverridesButtonSelectionStyle.Draw(buttonRect, false, false, true, true);
                }

                Rect buttonBorder = new Rect(buttonRect.x, buttonRect.y, buttonRect.width, 1);
                EditorGUI.DrawRect(buttonBorder, horizontalLineColor);// Upper border.

                buttonBorder.y = buttonRect.y + buttonRect.height;
                EditorGUI.DrawRect(buttonBorder, horizontalLineColor);// Lower border.

                Styles.removeOverridesButtonLineStyle.Draw(buttonRect, Styles.removeUnusedOverridesButtonContent, false, false, UnusedOverridesViewPopup.s_IsOpen, true);
            }

            var isHovered = buttonRect.Contains(UnityEngine.Event.current.mousePosition);

            if (isHovered)
            {
                GUIView.current.MarkHotRegion(GUIClip.UnclipToWindow(buttonRect));

                using (new GUI.BackgroundColorScope(GameObjectStyles.hoveredBackgroundColor))
                {
                    GUI.Label(buttonRect, GUIContent.none, GameObjectStyles.hoveredItemBackgroundStyle);
                }
            }

            if (GUI.Button(buttonRect, GUIContent.none, GUIStyle.none))
            {
                PopupWindowWithoutFocus.Show(buttonRect,
                                             new UnusedOverridesViewPopup(m_SelectedGameObjects, this),
                                             new[] { PopupLocation.Left, PopupLocation.Right });
            }
        }
 public static void Show(Rect activatorRect, PopupWindowContent windowContent)
 {
     PopupWindowWithoutFocus.Show(activatorRect, windowContent, (PopupLocationHelper.PopupLocation[])null);
 }
 public static void Show(Rect activatorRect, PopupWindowContent windowContent)
 {
     PopupWindowWithoutFocus.Show(activatorRect, windowContent, null);
 }