Пример #1
0
    public void drawEntity(NodeMEntity entity)
    {
        string name = "Entity";

        if (entity.entityName != "")
        {
            name = entity.entityName;
        }

        if (entity.orientation == PortOrientation.In)
        {
            //SirenixEditorGUI.
            SirenixEditorGUI.BeginIndentedHorizontal();
            SirenixEditorGUI.BeginBox();
            Rect rect = EditorGUILayout.GetControlRect();
            //  rect = EditorGUI.PrefixLabel(rect, new GUIContent("   "));


            rect = EditorGUI.PrefixLabel(rect, new GUIContent(name));

            if (GUI.Button(rect.AlignRight(15), EditorIcons.ArrowDown.Raw))
            {
                entity.style.unfolded = !entity.style.unfolded;
            }
            ;
            SirenixEditorGUI.EndBox();
            SirenixEditorGUI.EndIndentedHorizontal();
            // NodeEditorGUILayout.AddPortField(entity.port);
        }
        else
        {
            SirenixEditorGUI.BeginBox();
            Rect rect = EditorGUILayout.GetControlRect();
            EditorGUI.LabelField(rect.AlignRight(80), name);
            if (GUI.Button(rect.AlignLeft(15), EditorIcons.ArrowDown.Raw))
            {
                entity.style.unfolded = !entity.style.unfolded;
            }
            ;

            SirenixEditorGUI.EndBox();
            //  NodeEditorGUILayout.AddPortField(entity.port);
        }
        //  entity.style.unfolded = SirenixEditorGUI.Foldout(entity.style.unfolded, "");


        if (entity.style.unfolded)
        {
            SirenixEditorGUI.BeginBox();
            for (int i = 0; i < entity.components.Count; i++)
            {
                drawComponent(entity.components[i]);
            }
            SirenixEditorGUI.EndBox();
        }
        else
        {
            NodeEditorGUILayout.AddPortField(entity.port);
        }
    }
Пример #2
0
        private void DrawFirstToolbar()
        {
            //选项
            GUILayout.Space(1);
            Rect rect = GUILayoutUtility.GetRect(0f, ToolbarHeight, SirenixGUIStyles.ToolbarBackground);

            rect = rect.SetHeight(ToolbarHeight);
            var  opptionWidth = SirenixGUIStyles.LeftAlignedCenteredLabel.CalcSize(this.m_optionGui).x * 2f;
            Rect leftRect     = rect.AlignLeft(opptionWidth);

            OdinSelector <int> .DrawSelectorDropdown(leftRect, this.m_optionGui, this.SelectType, btnStyle);

            //搜索
            Rect filterRect = rect.AlignRight(opptionWidth * 2);
            Rect searchRect = rect.SetXMax(filterRect.xMin).SetXMin(opptionWidth);

            searchRect            = searchRect.HorizontalPadding(5f).AlignMiddle(16);
            this.m_sSearchKeyName = SirenixEditorGUI.SearchField(searchRect, this.m_sSearchKeyName);
            //数据类型过滤
            EditorGUI.BeginChangeCheck();
            this.m_eDataFilterType = EnumSelector <EPlayerPrefsType> .DrawEnumField(filterRect, null, new GUIContent("Type Filter"), this.m_eDataFilterType, CaomaoPlayerPrefsWindow.btnStyle);

            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt("CaomaoPlayerPrefsWindow.m_eDataFilterType", (int)this.m_eDataFilterType);
            }
        }
    protected override void DrawPropertyLayout(GUIContent label)
    {
        Rect   rect      = EditorGUILayout.GetControlRect();
        Color  tempColor = this.ValueEntry.SmartValue;
        string hexCode   = ColorUtility.ToHtmlStringRGB(tempColor);

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        rect      = EditorGUILayout.GetControlRect();
        tempColor = SirenixEditorFields.ColorField(rect.AlignLeft(rect.width * 0.75f), tempColor);

        //hexcode
        hexCode = SirenixEditorFields.TextField(rect.AlignRight(rect.width * 0.25f), "#" + hexCode);
        if (ColorUtility.TryParseHtmlString(hexCode, out tempColor))
        {
            this.ValueEntry.SmartValue = tempColor;
        }

        //rgb values
        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(15);
        tempColor.r = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.3f), "R", tempColor.r, 0f, 1f);
        tempColor.g = EditorGUI.Slider(rect.AlignCenter(rect.width * 0.3f), "G", tempColor.g, 0f, 1f);
        tempColor.b = EditorGUI.Slider(rect.AlignRight(rect.width * 0.3f), "B", tempColor.b, 0f, 1f);
        GUIHelper.PopLabelWidth();

        //hsv values
        Color.RGBToHSV(tempColor, out float h, out float s, out float v);
        rect = EditorGUILayout.GetControlRect();

        GUIHelper.PushLabelWidth(15);
        h = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.3f), "H", h, 0f, 1f);
        s = EditorGUI.Slider(rect.AlignCenter(rect.width * 0.3f), "S", s, 0f, 1f);
        v = EditorGUI.Slider(rect.AlignRight(rect.width * 0.3f), "V", v, 0f, 1f);
        GUIHelper.PopLabelWidth();

        tempColor = Color.HSVToRGB(h, s, v);

        this.ValueEntry.SmartValue = tempColor;
    }
Пример #4
0
        [Test] public void Alignment()
        {
            Assert.AreEqual(new Rect(-5, -5, 10, 10), Rect.AlignCenter(0, 0, 10, 10));

            Assert.AreEqual(new Rect(0, -5, 10, 10), Rect.AlignLeft(0, 0, 10, 10));
            Assert.AreEqual(new Rect(-10, -5, 10, 10), Rect.AlignRight(0, 0, 10, 10));
            Assert.AreEqual(new Rect(-5, 0, 10, 10), Rect.AlignTop(0, 0, 10, 10));
            Assert.AreEqual(new Rect(-5, -10, 10, 10), Rect.AlignBottom(0, 0, 10, 10));

            Assert.AreEqual(new Rect(0, 0, 10, 10), Rect.AlignTopLeft(0, 0, 10, 10));
            Assert.AreEqual(new Rect(-10, 0, 10, 10), Rect.AlignTopRight(0, 0, 10, 10));
            Assert.AreEqual(new Rect(0, -10, 10, 10), Rect.AlignBottomLeft(0, 0, 10, 10));
            Assert.AreEqual(new Rect(-10, -10, 10, 10), Rect.AlignBottomRight(0, 0, 10, 10));
        }
Пример #5
0
    public void drawFilter(NodeFilter filter)
    {
        if (filter != null)
        {
            if (filter.orientation == PortOrientation.In)
            {
                SirenixEditorGUI.BeginBox();
                Rect rect = EditorGUILayout.GetControlRect();
                rect = EditorGUI.PrefixLabel(rect, new GUIContent("In filter"));
                if (GUI.Button(rect.AlignRight(15), EditorIcons.ArrowDown.Raw))
                {
                    filter.style.unfolded = !filter.style.unfolded;
                }
                ;
                SirenixEditorGUI.EndBox();
                // NodeEditorGUILayout.AddPortField(filter.port);
            }
            else
            {
                SirenixEditorGUI.BeginBox();
                Rect rect = EditorGUILayout.GetControlRect();
                EditorGUI.LabelField(rect.AlignRight(60), "Out filter");
                if (GUI.Button(rect.AlignLeft(15), EditorIcons.ArrowDown.Raw))
                {
                    filter.style.unfolded = !filter.style.unfolded;
                }
                ;
                SirenixEditorGUI.EndBox();
            }

            // NodeEditorGUILayout.


            if (filter.style.unfolded)
            {
                SirenixEditorGUI.BeginBox();
                for (int i = 0; i < filter.filter.Count; i++)
                {
                    drawEntity(filter.filter[i]);
                }
                SirenixEditorGUI.EndBox();
            }
            else
            {
                NodeEditorGUILayout.AddPortField(filter.port);
            }
        }
    }
Пример #6
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var  entry = this.ValueEntry;
            Rect rect  = EditorGUILayout.GetControlRect(label != null);

            //rect = EditorGUI.IndentedRect(rect);

            if (label != null)
            {
                rect = EditorGUI.PrefixLabel(rect, label);
            }

            const float arrowWidth = 20;

            var btnRightRect = rect.AlignRight(arrowWidth);
            var btnLeftRect  = btnRightRect;

            btnLeftRect.x       -= btnLeftRect.width;
            btnLeftRect.height  -= 1;
            btnRightRect.height -= 1;

            if (GUI.Button(btnLeftRect, GUIContent.none))
            {
                var names = Enum.GetNames(typeof(T));
                var name  = Enum.GetName(typeof(T), entry.SmartValue);

                var currNameIndex = (names as IList <string>).IndexOf(name);
                currNameIndex    = MathUtilities.Wrap(currNameIndex - 1, 0, names.Length);
                entry.SmartValue = (T)Enum.Parse(typeof(T), names[currNameIndex]);
            }

            if (GUI.Button(btnRightRect, GUIContent.none))
            {
                var names = Enum.GetNames(typeof(T));
                var name  = Enum.GetName(typeof(T), entry.SmartValue);

                var currNameIndex = (names as IList <string>).IndexOf(name);
                currNameIndex    = MathUtilities.Wrap(currNameIndex + 1, 0, names.Length);
                entry.SmartValue = (T)Enum.Parse(typeof(T), names[currNameIndex]);
            }

            EditorIcons.TriangleLeft.Draw(btnLeftRect.AlignCenter(16, 16));
            EditorIcons.TriangleRight.Draw(btnRightRect.AlignCenter(16, 16));

            rect.xMax -= btnRightRect.width * 2;

            entry.WeakSmartValue = SirenixEditorFields.EnumDropdown(rect, (Enum)entry.WeakSmartValue);
        }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            Rect rect = EditorGUILayout.GetControlRect();

            if (label != null)
            {
                rect = EditorGUI.PrefixLabel(rect, label);
            }
            MyStruct value = this.ValueEntry.SmartValue;

            GUIHelper.PushLabelWidth(20);
            value.X = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.5f), "X", value.X, 0, 100);
            value.Y = EditorGUI.Slider(rect.AlignRight(rect.width * 0.5f), "Y", value.Y, 0, 100);
            GUIHelper.PopLabelWidth();
            this.ValueEntry.SmartValue = value;
        }
Пример #8
0
    public Rect Draw(float width, float height, float x = 0, float y = 0)
    {
        Rect allRect = EditorGUILayout.BeginVertical();

        if (EditorGUIUtility.isProSkin)
        {
            EditorGUI.DrawRect(new Rect(x, allRect.yMax, width, height), SirenixGUIStyles.DarkEditorBackground);
        }
        else
        {
            EditorGUI.DrawRect(new Rect(x, y, width, allRect.yMax), SirenixGUIStyles.BoxBackgroundColor);
        }
        Rect rect = GUILayoutUtility.GetRect(0f, 70f);

        GUI.Label(rect.AlignCenterY(45f), this.logoContent,
                  CaomaoGUIStyle.HeaderStyle);
        float versionWidth = SirenixGUIStyles.CenteredGreyMiniLabel.CalcSize(CaomaoGUIContent.VersionContent).x;
        float developWidth = SirenixGUIStyles.CenteredGreyMiniLabel.CalcSize(CaomaoGUIContent.DevelopPlatformContent).x;
        var   maxWidth     = Mathf.Max(versionWidth, developWidth);
        Rect  rightRect    = rect.AlignRight(maxWidth + 10f);

        rightRect.x     -= 10f;
        rightRect.y     += 8f;
        rightRect.height = 17f;
        if (Event.current.type == EventType.Repaint)
        {
            GUI.Label(rightRect, CaomaoGUIContent.VersionContent, SirenixGUIStyles.CenteredGreyMiniLabel);
        }
        rightRect.y += 15f;
        if (Event.current.type == EventType.Repaint)
        {
            GUI.Label(rightRect, CaomaoGUIContent.DevelopPlatformContent, SirenixGUIStyles.CenteredGreyMiniLabel);
        }
        rightRect.y += rightRect.height + 4f;
        if (GUI.Button(rightRect, "版本信息", SirenixGUIStyles.MiniButton))
        {
            Application.OpenURL("https://odininspector.com/patch-notes");
        }
        SirenixEditorGUI.DrawHorizontalLineSeperator(rect.x, rect.y, rect.width, 0.5f);
        SirenixEditorGUI.DrawHorizontalLineSeperator(rect.x, rect.yMax + y, rect.width, 0.5f);
        this.DrawOhterHeader();
        EditorGUILayout.EndHorizontal();
        return(rect);
    }
Пример #9
0
        private void DrawFoldoutButton()
        {
            Rect btnRect = this.buttonHeight > 0 ?
                           GUILayoutUtility.GetRect(GUIContent.none, style, GUILayoutOptions.Height(this.buttonHeight)) :
                           GUILayoutUtility.GetRect(GUIContent.none, style);

            btnRect = EditorGUI.IndentedRect(btnRect);

            GUIHelper.PushColor(this.btnColor);

            var foldoutRect = btnRect.AlignRight(20);

            if (GUI.Button(foldoutRect, GUIContent.none, toggleBtnStyle))
            {
                this.toggle.Value = !this.toggle.Value;
            }

            btnRect.width -= foldoutRect.width;
            if (!this.toggle.Value)
            {
                foldoutRect.x    -= 1;
                foldoutRect.yMin -= 1;
            }

            if (this.toggle.Value)
            {
                EditorIcons.TriangleDown.Draw(foldoutRect, 16);
            }
            else
            {
                EditorIcons.TriangleLeft.Draw(foldoutRect, 16);
            }

            if (GUI.Button(btnRect, this.label, this.style))
            {
                this.InvokeButton();
            }

            GUIHelper.PopColor();

            EditorGUI.indentLevel++;
            this.DrawParameters(false);
            EditorGUI.indentLevel--;
        }
        /// <summary>
        /// Handles the Minesweeper game.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            Rect rect = EditorGUILayout.GetControlRect();

            this.ValueEntry.SmartValue = Mathf.Clamp(SirenixEditorFields.IntField(rect.AlignLeft(rect.width - 80 - 4), "Number of Bombs", this.ValueEntry.SmartValue), 1, (BoardSize * BoardSize) / 4);

            // Start game
            if (GUI.Button(rect.AlignRight(80), "Start"))
            {
                this.StartGame(this.ValueEntry.SmartValue);
            }

            // Game
            SirenixEditorGUI.BeginShakeableGroup(this.Key);
            if (this.isRunning)
            {
                this.Game();
            }
            SirenixEditorGUI.EndShakeableGroup(this.Key);
        }
Пример #11
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        Rect rect = EditorGUILayout.GetControlRect();

        if (label != null)
        {
            rect = EditorGUI.PrefixLabel(rect, label);
        }

        Vector2 value = this.ValueEntry.SmartValue;

        GUIHelper.PushLabelWidth(20);
        value.x = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.5f), "X", value.x,
                                   this.Attribute.minValue, this.Attribute.maxValue);
        value.y = EditorGUI.Slider(rect.AlignRight(rect.width * 0.5f), "Y", value.y,
                                   this.Attribute.minValue, this.Attribute.maxValue);
        GUIHelper.PopLabelWidth();

        this.ValueEntry.SmartValue = value;
    }
Пример #12
0
    public override void OnBodyGUI()
    {
        base.OnBodyGUI();

        if (node.filter != null)
        {
            drawFilter(node.filter);
        }


        Rect rect = EditorGUILayout.GetControlRect();

        if (GUI.Button(rect.AlignRight(20), EditorIcons.CharGraph.Raw))
        {
            // OdinEditorWindow.InspectObject(node.filter);
            connectNode();
            //   Debug.Log("connected");
        }

        //  node.filter.port.s
    }
Пример #13
0
    protected override void DrawPropertyLayout(GUIContent label)
    {
        if (InterfaceScriptableObjectAssetSelector == null)
        {
            InterfaceScriptableObjectAssetSelector = new GenericAssetSelector <T>(
                (T p_selectedAsset) => { ValueEntry.SmartValue = p_selectedAsset; });
        }

        Rect rect = EditorGUILayout.GetControlRect();

        ScriptableObject l_selectedScriptableObject = (ScriptableObject)EditorGUI.ObjectField(rect.SetWidth(rect.width * 0.9f), ValueEntry.SmartValue as ScriptableObject, typeof(ScriptableObject), false);

        if (l_selectedScriptableObject is IAnimationPlayableDefinition)
        {
            ValueEntry.SmartValue = (T)(IAnimationPlayableDefinition)l_selectedScriptableObject;
        }


        if (GUI.Button(rect.AlignRight(rect.width * 0.1f), TreeSelectionButtonGUIContent))
        {
            InterfaceScriptableObjectAssetSelector.ShowInPopup();
        }
    }
Пример #14
0
    public override void OnBodyGUI()
    {
        base.OnBodyGUI();
        //nodeposition = NodeEditorWindow.current.lastMousePosition;

        if (node.nodeInFilter != null)
        {
            window.Repaint();
            drawFilter(node.nodeInFilter);
        }

        if (node.nodeOutFilter != null)
        {
            window.Repaint();
            drawFilter(node.nodeOutFilter);
        }

        Rect rect = EditorGUILayout.GetControlRect();

        if (GUI.Button(rect.AlignRight(20), EditorIcons.CharGraph.Raw))
        {
            connectNode();
        }
    }
Пример #15
0
        private void DrawColumnHeaders()
        {
            var columnsRect = GUILayoutUtility.GetRect(0, this.Tree.Config.DefaultMenuStyle.Height, GUILayoutOptions.ExpandWidth(true));

            EditorGUI.DrawRect(columnsRect, SirenixGUIStyles.DarkEditorBackground);

            //SirenixGUIStyles.Temporary.Draw(columnsRect, GUIContent.none, 0);

            int   columnIndex = 0;
            float currentX    = columnsRect.xMin;

            for (int i = 0; i < AllDisplayOptions.Length; i++)
            {
                var option = AllDisplayOptions[i];

                if ((this.Display & option) == option)
                {
                    var width = this.columns[columnIndex].ColWidth;
                    var rect  = new Rect(currentX, columnsRect.yMin + 3, width - 0.5f, columnsRect.height);

                    rect.xMax = Math.Min(rect.xMax, columnsRect.xMax);

                    if (rect.width <= 0)
                    {
                        break;
                    }

                    var labelText = option == DisplayOptions.Category ? "" : option.ToString();

                    if (GUI.Button(rect, GUIHelper.TempContent(labelText), SirenixGUIStyles.BoldLabel))
                    {
                        if (this.SortBy == option)
                        {
                            this.SortAscending = !this.SortAscending;
                        }
                        else
                        {
                            this.SortBy        = option;
                            this.SortAscending = false;
                        }

                        this.shouldSort = true;
                    }

                    var        iconRect = rect.AlignRight(rect.height).Padding(3).SubY(3);
                    EditorIcon icon;

                    if (this.SortBy != option)
                    {
                        icon = EditorIcons.TriangleRight;
                        GUIHelper.PushColor(GUI.color * 0.7f);
                    }
                    else
                    {
                        icon = this.SortAscending ? EditorIcons.TriangleUp : EditorIcons.TriangleDown;
                    }

                    icon.Draw(iconRect);

                    if (this.SortBy != option)
                    {
                        GUIHelper.PopColor();
                    }

                    currentX += width;
                    columnIndex++;
                }
            }

            SirenixEditorGUI.DrawHorizontalLineSeperator(columnsRect.xMin, columnsRect.yMax, columnsRect.width, 0.5f);
        }
Пример #16
0
        public void AddErrorAndWarningIcons()
        {
            Dictionary <OdinMenuItem, int> errorCount   = new Dictionary <OdinMenuItem, int>();
            Dictionary <OdinMenuItem, int> warningCount = new Dictionary <OdinMenuItem, int>();
            int maxECount = 0;
            int maxWCount = 0;

            foreach (OdinMenuItem mi in this.EnumerateTree())
            {
                ValidationProfileResult result = mi.Value as ValidationProfileResult;
                if (result == null || result.Results == null || result.Results.Count == 0)
                {
                    continue;
                }

                int ec = result.Results.Count(x => x.ResultType == ValidationResultType.Error);
                int wc = result.Results.Count(x => x.ResultType == ValidationResultType.Warning);

                foreach (OdinMenuItem mm in mi.GetParentMenuItemsRecursive(true))
                {
                    if (!errorCount.ContainsKey(mm))
                    {
                        errorCount[mm] = 0;
                    }
                    if (!warningCount.ContainsKey(mm))
                    {
                        warningCount[mm] = 0;
                    }
                    maxECount = Math.Max(ec, errorCount[mm] += ec);
                    maxWCount = Math.Max(wc, warningCount[mm] += wc);
                }
            }

            //var wStyle = new GUIStyle("sv_label_5");
            //var eStyle = new GUIStyle("sv_label_6");
            //wStyle.alignment = TextAnchor.MiddleCenter;
            //eStyle.alignment = TextAnchor.MiddleCenter;

            float eCountWidth = SirenixGUIStyles.LeftAlignedWhiteMiniLabel.CalcSize(new GUIContent(maxECount + " ")).x;
            float wCountWidth = SirenixGUIStyles.LeftAlignedWhiteMiniLabel.CalcSize(new GUIContent(maxWCount + " ")).x;

            wCountWidth = eCountWidth = Mathf.Max(eCountWidth, wCountWidth);

            foreach (OdinMenuItem mi in this.EnumerateTree())
            {
                if (!errorCount.ContainsKey(mi))
                {
                    errorCount[mi] = 0;
                }
                if (!warningCount.ContainsKey(mi))
                {
                    warningCount[mi] = 0;
                }

                int        ec  = errorCount[mi];
                int        wc  = warningCount[mi];
                GUIContent ecl = new GUIContent(ec + "");
                GUIContent wcl = new GUIContent(wc + "");

                mi.OnDrawItem += (m) =>
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        Rect rect = m.Rect.Padding(10, 5);
                        rect.height += 1;
                        Rect errorRect   = rect.AlignRight(eCountWidth);
                        Rect warningRect = errorRect.SubX(wCountWidth - 1);
                        warningRect.width = wCountWidth;

                        bool hasErrors = ec > 0;
                        if (hasErrors)
                        {
                            SirenixEditorGUI.DrawSolidRect(errorRect, red);
                            //SirenixEditorGUI.DrawBorders(errorRect, 1);
                            errorRect.y -= 1;
                            errorRect.x -= 1;
                            GUI.Label(errorRect, ecl, SirenixGUIStyles.CenteredWhiteMiniLabel);
                        }

                        bool hasWarnings = wc > 0;
                        if (hasWarnings)
                        {
                            warningRect.x -= 1;
                            SirenixEditorGUI.DrawSolidRect(warningRect, orange);
                            //SirenixEditorGUI.DrawBorders(warningRect, 1);
                            warningRect.y -= 1;
                            GUI.Label(warningRect, wcl, SirenixGUIStyles.CenteredBlackMiniLabel);
                        }
                    }
                };
            }
        }
        private void DrawColumn(Rect rect, IPropertyValueEntry <TArray> entry, Context context, int columnIndex)
        {
            if (columnIndex < context.ColCount)
            {
                GUI.Label(rect, columnIndex.ToString(), SirenixGUIStyles.LabelCentered);

                // Handle Column dragging.
                if (!context.Attribute.IsReadOnly)
                {
                    var id = GUIUtility.GetControlID(FocusType.Passive);
                    if (GUI.enabled && Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                    {
                        GUIHelper.RemoveFocusControl();
                        GUIUtility.hotControl = id;
                        EditorGUIUtility.SetWantsMouseJumping(1);
                        Event.current.Use();
                        context.ColumnDragFrom = columnIndex;
                        context.ColumnDragTo   = columnIndex;
                        context.dragStartPos   = Event.current.mousePosition;
                    }
                    else if (GUIUtility.hotControl == id)
                    {
                        if ((context.dragStartPos - Event.current.mousePosition).sqrMagnitude > 5 * 5)
                        {
                            context.IsDraggingColumn = true;
                        }
                        if (Event.current.type == EventType.MouseDrag)
                        {
                            Event.current.Use();
                        }
                        else if (Event.current.type == EventType.MouseUp)
                        {
                            GUIUtility.hotControl = 0;
                            EditorGUIUtility.SetWantsMouseJumping(0);
                            Event.current.Use();
                            context.IsDraggingColumn = false;

                            ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.MoveColumn(arr, context.ColumnDragFrom, context.ColumnDragTo));
                        }
                    }

                    if (context.IsDraggingColumn && Event.current.type == EventType.Repaint)
                    {
                        float mouseX = Event.current.mousePosition.x;
                        if (mouseX > rect.x - 1 && mouseX < rect.x + rect.width + 1)
                        {
                            Rect arrowRect;
                            if (mouseX > rect.x + rect.width * 0.5f)
                            {
                                arrowRect            = rect.AlignRight(16);
                                arrowRect.height     = 16;
                                arrowRect.y         -= 13;
                                arrowRect.x         += 8;
                                context.ColumnDragTo = columnIndex;
                            }
                            else
                            {
                                arrowRect            = rect.AlignLeft(16);
                                arrowRect.height     = 16;
                                arrowRect.y         -= 13;
                                arrowRect.x         -= 8;
                                context.ColumnDragTo = columnIndex - 1;
                            }

                            entry.Property.Tree.DelayActionUntilRepaint(() =>
                            {
                                //GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
                                GUI.DrawTexture(arrowRect, EditorIcons.ArrowDown.Active);
                                //GL.sRGBWrite = false;

                                var lineRect   = arrowRect;
                                lineRect.x     = lineRect.center.x - 2 + 1;
                                lineRect.width = 3;
                                lineRect.y    += 14;
                                lineRect.yMax  = context.Table.TableRect.yMax;
                                EditorGUI.DrawRect(lineRect, new Color(0, 0, 0, 0.6f));
                            });
                        }

                        if (columnIndex == context.ColCount - 1)
                        {
                            entry.Property.Tree.DelayActionUntilRepaint(() =>
                            {
                                var cell     = context.Table[context.Table.ColumnCount - context.ColCount + context.ColumnDragFrom, context.Table.RowCount - 1];
                                var rowRect  = cell.Rect;
                                rowRect.yMin = rect.yMin;
                                SirenixEditorGUI.DrawSolidRect(rowRect, new Color(0, 0, 0, 0.2f));
                            });
                        }
                    }
                }
            }
            else
            {
                GUI.Label(rect, "-", EditorStyles.centeredGreyMiniLabel);
            }

            if (!context.Attribute.IsReadOnly && Event.current.type == EventType.MouseDown && Event.current.button == 1 && rect.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Insert 1 left"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneColumnLeft(arr, columnIndex)));
                menu.AddItem(new GUIContent("Insert 1 right"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.InsertOneColumnRight(arr, columnIndex)));
                menu.AddItem(new GUIContent("Duplicate"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DuplicateColumn(arr, columnIndex)));
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Delete"), false, () => ApplyArrayModifications(entry, arr => MultiDimArrayUtilities.DeleteColumn(arr, columnIndex)));
                menu.ShowAsContext();
            }
        }
Пример #18
0
        /// <summary>
        /// Draws right-aligned toolbar paging buttons.
        /// </summary>
        public void DrawToolbarPagingButtons(ref Rect toolbarRect, bool showPaging, bool showItemCount, int btnWidth = 23)
        {
            if (this.prevRect.height == 0)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    this.prevRect = toolbarRect;
                }

                return;
            }

            //var isRepaint = Event.current.type == EventType.Repaint;
            var drawPaging      = this.isEnabled && !this.IsExpanded && showPaging && this.pageCount > 1; // btnWith * 2
            var drawExpand      = this.isEnabled && this.pageCount > 1;                                   // btnWith
            var drawPagingField = drawPaging;                                                             // 40?

            // Expand
            if (drawExpand)
            {
                var btnRect = toolbarRect.AlignRight(btnWidth, true);
                toolbarRect.xMax = btnRect.xMin;
                if (GUI.Button(btnRect, GUIContent.none, SirenixGUIStyles.ToolbarButton))
                {
                    GUIHelper.RemoveFocusControl();
                    this.nextIsExpanded = !this.IsExpanded;
                }
                (this.IsExpanded ? EditorIcons.TriangleUp : EditorIcons.TriangleDown).Draw(btnRect, 16);
            }

            // Right
            if (drawPaging)
            {
                //if (this.IsOnLastPage && isRepaint) GUIHelper.PushGUIEnabled(false);
                var btnRect = toolbarRect.AlignRight(btnWidth, true);
                if (GUI.Button(btnRect, GUIContent.none, SirenixGUIStyles.ToolbarButton))
                {
                    GUIHelper.RemoveFocusControl();
                    if (Event.current.button == 1)
                    {
                        this.nextPageNumber = this.PageCount - 1;
                    }
                    else
                    {
                        this.nextPageNumber = this.currentPage + 1;

                        if (this.nextPageNumber >= this.pageCount)
                        {
                            this.nextPageNumber = 0;
                        }
                    }
                }
                EditorIcons.TriangleRight.Draw(btnRect, 16);
                //if (this.IsOnLastPage && isRepaint) GUIHelper.PopGUIEnabled();
                toolbarRect.xMax = btnRect.xMin;
            }

            // Paging field
            if (drawPagingField)
            {
                var pageCountLbl = "/ " + this.PageCount.ToString();
                var lblLength    = SirenixGUIStyles.Label.CalcSize(new GUIContent(pageCountLbl)).x;
                var lblRect      = toolbarRect.AlignRight(lblLength + 5, true);
                toolbarRect.xMax = lblRect.xMin;
                var fldRect = toolbarRect.AlignRight(lblLength, true);
                toolbarRect.xMax = fldRect.xMin;
                fldRect.xMin    += 4;
                fldRect.y       -= 1;
                GUI.Label(lblRect, pageCountLbl, SirenixGUIStyles.LabelCentered);

                var next = SirenixEditorGUI.SlideRectInt(lblRect, 0, this.CurrentPage);
                if (next != this.CurrentPage)
                {
                    this.nextPageNumber = next;
                }

                next = EditorGUI.IntField(fldRect.AlignCenterY(15), this.CurrentPage + 1) - 1;
                if (next != this.CurrentPage)
                {
                    this.nextPageNumber = next;
                }
            }

            // Left
            if (drawPaging)
            {
                //if (this.IsOnFirstPage && isRepaint) GUIHelper.PushGUIEnabled(false);
                var btnRect = toolbarRect.AlignRight(btnWidth, true);
                if (GUI.Button(btnRect, GUIContent.none, SirenixGUIStyles.ToolbarButton))
                {
                    GUIHelper.RemoveFocusControl();
                    if (Event.current.button == 1)
                    {
                        this.nextPageNumber = 0;
                    }
                    else
                    {
                        this.nextPageNumber = this.currentPage - 1;

                        if (this.nextPageNumber < 0)
                        {
                            this.nextPageNumber = this.pageCount - 1;
                        }
                    }
                }
                EditorIcons.TriangleLeft.Draw(btnRect, 16);
                //if (this.IsOnFirstPage && isRepaint) GUIHelper.PopGUIEnabled();
                toolbarRect.xMax = btnRect.xMin;
            }

            // Item Count
            if (showItemCount && Event.current.type != EventType.Layout)
            {
                var lbl     = new GUIContent(this.ElementCount == 0 ? "Empty" : this.ElementCount + " items");
                var width   = SirenixGUIStyles.LeftAlignedGreyMiniLabel.CalcSize(lbl).x + 5;
                var lblRect = toolbarRect.AlignRight(width);
                GUI.Label(lblRect, lbl, SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                toolbarRect.xMax = lblRect.xMin;
            }

            if (Event.current.type == EventType.Repaint)
            {
                this.prevRect = toolbarRect;
            }
        }
Пример #19
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
        {
            Context context;

            if (entry.Context.Get(this, "context", out context))
            {
                context.UniqueControlName = Guid.NewGuid().ToString();
            }

            if (!context.IsValid)
            {
                GUIHelper.PushColor(Color.red);
            }

            GUI.SetNextControlName(context.UniqueControlName);

            Rect rect = EditorGUILayout.GetControlRect();

            if (label != null)
            {
                rect = EditorGUI.PrefixLabel(rect, label);
            }

            Rect fieldRect    = rect;
            Rect dropdownRect = rect.AlignRight(18);

            // Dropdown button.
            EditorGUIUtility.AddCursorRect(dropdownRect, MouseCursor.Arrow);
            if (GUI.Button(dropdownRect, GUIContent.none, GUIStyle.none))
            {
                TypeSelector selector = new TypeSelector(AssemblyTypeFlags.All, false);

                selector.SelectionConfirmed += t =>
                {
                    var type = t.FirstOrDefault();

                    entry.Property.Tree.DelayAction(() =>
                    {
                        entry.WeakSmartValue = type;
                        context.IsValid      = true;
                        entry.ApplyChanges();
                    });
                };

                selector.SetSelection(entry.SmartValue);
                selector.ShowInPopup(rect, 350);
            }

            // Reset type name.
            if (Event.current.type == EventType.Layout)
            {
                context.TypeNameTemp = entry.SmartValue != null?Binder.BindToName(entry.SmartValue) : null;
            }

            EditorGUI.BeginChangeCheck();
            context.TypeNameTemp = SirenixEditorFields.DelayedTextField(fieldRect, context.TypeNameTemp);

            // Draw dropdown button.
            EditorIcons.TriangleDown.Draw(dropdownRect);

            if (!context.IsValid)
            {
                GUIHelper.PopColor();
            }

            bool isFocused = GUI.GetNameOfFocusedControl() == context.UniqueControlName;
            bool defocused = false;

            if (isFocused != context.WasFocusedControl)
            {
                defocused = !isFocused;
                context.WasFocusedControl = isFocused;
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (string.IsNullOrEmpty(context.TypeNameTemp.Trim()))
                {
                    // String is empty
                    entry.SmartValue = null;
                    context.IsValid  = true;
                }
                else
                {
                    Type type = Binder.BindToType(context.TypeNameTemp);

                    if (type == null)
                    {
                        type = AssemblyUtilities.GetTypeByCachedFullName(context.TypeNameTemp);
                    }

                    if (type == null)
                    {
                        context.IsValid = false;
                    }
                    else
                    {
                        // Use WeakSmartValue in case of a different Type-derived instance showing up somehow, so we don't get cast errors
                        entry.WeakSmartValue = type;
                        context.IsValid      = true;
                    }
                }
            }

            if (defocused)
            {
                // Ensure we show the full type name when the control is defocused
                context.TypeNameTemp = entry.SmartValue == null ? "" : Binder.BindToName(entry.SmartValue);
                context.IsValid      = true;
            }
        }
Пример #20
0
        /// <summary>
        /// Handles the Minesweeper game.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <int> entry, MinesweeperAttribute attribute, GUIContent label)
        {
            PropertyContext <GameContext> context;

            if (entry.Context.Get(this, "GameContext", out context))
            {
                context.Value = new GameContext()
                {
                    IsRunning    = false,
                    GameOver     = false,
                    VisibleTiles = new Tile[BoardSize, BoardSize],
                    Tiles        = new Tile[BoardSize, BoardSize],
                    Key          = new object(),
                };
            }

            GameContext game = context.Value;

            Rect rect = EditorGUILayout.GetControlRect();

            entry.SmartValue = Mathf.Clamp(SirenixEditorFields.IntField(rect.AlignLeft(rect.width - 80 - 4), "Number of Bombs", entry.SmartValue), 1, (BoardSize * BoardSize) / 4);

            // Start game
            if (GUI.Button(rect.AlignRight(80), "Start"))
            {
                game.NumberOfBombs = entry.SmartValue;
                game.FlaggedBombs  = 0;

                for (int x = 0; x < BoardSize; x++)
                {
                    for (int y = 0; y < BoardSize; y++)
                    {
                        game.VisibleTiles[x, y] = Tile.None;
                        game.Tiles[x, y]        = Tile.None;
                    }
                }

                // Spawn bombs.
                for (int count = 0; count < game.NumberOfBombs;)
                {
                    int x = UnityEngine.Random.Range(0, BoardSize);
                    int y = UnityEngine.Random.Range(0, BoardSize);

                    if (game.Tiles[x, y] != Tile.Bomb)
                    {
                        game.Tiles[x, y] = Tile.Bomb;

                        if (x + 1 < BoardSize && game.Tiles[x + 1, y] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y] = (Tile)((int)game.Tiles[x + 1, y] + 1);
                        }
                        if (x + 1 < BoardSize && y + 1 < BoardSize && game.Tiles[x + 1, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y + 1] = (Tile)((int)game.Tiles[x + 1, y + 1] + 1);
                        }
                        if (y + 1 < BoardSize && game.Tiles[x, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x, y + 1] = (Tile)((int)game.Tiles[x, y + 1] + 1);
                        }
                        if (x - 1 >= 0 && y + 1 < BoardSize && game.Tiles[x - 1, y + 1] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y + 1] = (Tile)((int)game.Tiles[x - 1, y + 1] + 1);
                        }

                        if (x - 1 >= 0 && game.Tiles[x - 1, y] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y] = (Tile)((int)game.Tiles[x - 1, y] + 1);
                        }
                        if (x - 1 >= 0 && y - 1 >= 0 && game.Tiles[x - 1, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x - 1, y - 1] = (Tile)((int)game.Tiles[x - 1, y - 1] + 1);
                        }
                        if (y - 1 >= 0 && game.Tiles[x, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x, y - 1] = (Tile)((int)game.Tiles[x, y - 1] + 1);
                        }
                        if (x + 1 < BoardSize && y - 1 >= 0 && game.Tiles[x + 1, y - 1] != Tile.Bomb)
                        {
                            game.Tiles[x + 1, y - 1] = (Tile)((int)game.Tiles[x + 1, y - 1] + 1);
                        }

                        count++;
                    }
                }
                game.IsRunning = true;
                game.GameOver  = false;
                game.PrevTime  = EditorApplication.timeSinceStartup;
                game.Time      = 0;
            }

            // Game

            SirenixEditorGUI.BeginShakeableGroup(game.Key);
            if (game.IsRunning)
            {
                this.Game(game);
            }
            SirenixEditorGUI.EndShakeableGroup(game.Key);
        }
Пример #21
0
    protected override void OnGUI()
    {
        _repaintSheduled = false;
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Clear"))
        {
            _properties.Clear();
        }

        Rect settingsRect = GUILayoutUtility.GetRect(24, 24, GUILayout.ExpandWidth(false)).AlignLeft(20).AlignCenterY(20);

        if (SirenixEditorGUI.IconButton(settingsRect, _showSettings ? EditorIcons.SettingsCog.Inactive : EditorIcons.SettingsCog.Active, "Settings"))
        {
            _showSettings = !_showSettings;
        }
        GUILayout.EndHorizontal();

        if (_showSettings)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(40);
            GUI.changed = false;
            Rect rect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true));
            _labelWidth = GUI.HorizontalSlider(rect, _labelWidth, rect.xMin, rect.xMax);
            if (GUI.changed)
            {
                EditorPrefs.SetFloat("OWW_labelWidth", _labelWidth);
            }
            EditorGUILayout.LabelField("Label Width", GUILayout.Width(70));
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(5);
        bool first = true;

        if (_properties.Count == 0)
        {
            EditorGUILayout.LabelField("Right-click any property in an Inspector and select 'Watch' to make it show up here.", SirenixGUIStyles.MultiLineCenteredLabel);
        }

        GUIHelper.PushLabelWidth(_labelWidth - 30);

        for (int i = 0; i < _properties.Count; i++)
        {
            TreeValuesHolder holder = _properties[i];
            holder.CheckRefresh();
            if (!first)
            {
                GUILayout.Space(5);
            }
            first = false;

            Rect titleRect = SirenixEditorGUI.BeginBox("      " + holder.Tree.TargetType.Name);

            titleRect = titleRect.AlignTop(21);
            if (holder.ParentObject != null)
            {
                Rect alignRight = titleRect.AlignRight(200).AlignCenterY(16).AlignLeft(180);
                GUIHelper.PushGUIEnabled(false);
                SirenixEditorFields.UnityObjectField(alignRight, holder.ParentObject, typeof(GameObject), true);
                GUIHelper.PopGUIEnabled();
            }

            if (SirenixEditorGUI.IconButton(titleRect.AlignRight(20).AlignCenterY(18), EditorIcons.X))
            {
                _properties.RemoveAt(i--);
            }

            Rect titleDragDropRect = titleRect.AlignLeft(30).AlignCenter(20, 20);
            EditorIcons.List.Draw(titleDragDropRect);

            TreeValuesHolder treedragdrop = (TreeValuesHolder)DragAndDropUtilities.DragAndDropZone(titleDragDropRect, holder, typeof(TreeValuesHolder), false, false);
            if (treedragdrop != holder)
            {
                int treeDragDropIndex = _properties.IndexOf(treedragdrop);
                Swap(_properties, treeDragDropIndex, i);
            }

            if (holder.Tree.UnitySerializedObject?.targetObject == null)
            {
                EditorGUILayout.LabelField($"This component is no longer valid in the current context (loaded different scene?)", SirenixGUIStyles.MultiLineLabel);
            }
            else
            {
                InspectorUtilities.BeginDrawPropertyTree(holder.Tree, true);
                for (int index = 0; index < holder.ValuePaths.Count; index++)
                {
                    string path = holder.ValuePaths[index];
                    GUILayout.BeginHorizontal();

                    Rect rect1 = GUILayoutUtility.GetRect(EditorGUIUtility.singleLineHeight + 5, EditorGUIUtility.singleLineHeight + 3, GUILayout.ExpandWidth(false)).AlignRight(EditorGUIUtility.singleLineHeight + 2);

                    EditorIcons.List.Draw(rect1);

                    ValueDragDropHolder dragdrop = (ValueDragDropHolder)DragAndDropUtilities.DragAndDropZone(rect1, new ValueDragDropHolder(holder, index), typeof(ValueDragDropHolder), false, false);
                    if (dragdrop.TreeValuesHolder == holder && dragdrop.Index != index)
                    {
                        string ptemp = holder.ValuePaths[index];
                        holder.ValuePaths[index]          = holder.ValuePaths[dragdrop.Index];
                        holder.ValuePaths[dragdrop.Index] = ptemp;
                    }

                    InspectorProperty propertyAtPath = holder.Tree.GetPropertyAtPath(path);
                    if (propertyAtPath == null)
                    {
                        propertyAtPath = holder.Tree.GetPropertyAtUnityPath(path);
                    }
                    if (propertyAtPath != null)
                    {
                        propertyAtPath.Draw();
                    }
                    else
                    {
                        EditorGUILayout.LabelField($"Could not find property ({path})");
                    }

                    if (SirenixEditorGUI.IconButton(EditorIcons.X))
                    {
                        holder.ValuePaths.RemoveAt(index--);
                        if (holder.ValuePaths.Count == 0)
                        {
                            _properties.RemoveAt(i--);
                        }
                    }

                    GUILayout.Space(3);
                    GUILayout.EndHorizontal();
                }

                InspectorUtilities.EndDrawPropertyTree(holder.Tree);
            }

            SirenixEditorGUI.EndBox();
        }

        GUIHelper.PopLabelWidth();
    }
        /// <summary>
        /// Draws a objectpicker button in the given rect. This one is designed to look good on top of DrawDropZone().
        /// </summary>
        public static object ObjectPickerZone(Rect rect, object value, Type type, bool allowSceneObjects, int id)
        {
            // TODO: btnId wasn't used, but the GetControlID call is probably still important.
            //var btnId = GUIUtility.GetControlID(FocusType.Passive);
            GUIUtility.GetControlID(FocusType.Passive);
            var objectPicker = ObjectPicker.GetObjectPicker(type.FullName + "+" + GUIHelper.CurrentWindowInstanceID.ToString() + "+" + id, type);
            var selectRect   = rect.AlignBottom(15).AlignCenter(45);
            var uObj         = value as UnityEngine.Object;

            selectRect.xMin = Mathf.Max(selectRect.xMin, rect.xMin);

            var hide = IsDragging || Event.current.type == EventType.Repaint && !rect.Contains(Event.current.mousePosition);

            if (hide)
            {
                GUIHelper.PushColor(new Color(0, 0, 0, 0));
                GUIHelper.PushGUIEnabled(false);
            }

            bool hideInspectorBtn = !hide && !(uObj);

            if (hideInspectorBtn)
            {
                GUIHelper.PushGUIEnabled(false);
                GUIHelper.PushColor(new Color(0, 0, 0, 0));
            }

            var inspectBtn = rect.AlignRight(14);

            inspectBtn.height = 14;
            SirenixEditorGUI.BeginDrawOpenInspector(inspectBtn, uObj, rect);
            SirenixEditorGUI.EndDrawOpenInspector(inspectBtn, uObj);

            if (hideInspectorBtn)
            {
                GUIHelper.PopColor();
                GUIHelper.PopGUIEnabled();
            }

            if (GUI.Button(selectRect, "select", SirenixGUIStyles.TagButton))
            {
                GUIHelper.RemoveFocusControl();
                objectPicker.ShowObjectPicker(value, allowSceneObjects, rect, false);
                Event.current.Use();
            }

            if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id)
            {
                objectPicker.ShowObjectPicker(value, allowSceneObjects, rect, false);
                Event.current.Use();
            }

            if (hide)
            {
                GUIHelper.PopColor();
                GUIHelper.PopGUIEnabled();
            }

            if (objectPicker.IsReadyToClaim)
            {
                GUIHelper.RequestRepaint();
                GUI.changed = true;
                var newValue = objectPicker.ClaimObject();
                Event.current.Use();
                return(newValue);
            }

            if (objectPicker.IsPickerOpen && typeof(UnityEngine.Object).IsAssignableFrom(type))
            {
                return(objectPicker.CurrentSelectedObject);
            }

            if (Event.current.keyCode == KeyCode.Delete && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id)
            {
                Event.current.Use();
                GUI.changed = true;
                return(null);
            }

            if (uObj && Event.current.rawType == EventType.MouseUp && rect.Contains(Event.current.mousePosition) && Event.current.button == 0)
            {
                // For components ping the attached game object instead, because then Unity can figure out to ping prefabs in the project window too.
                UnityEngine.Object pingObj = uObj;
                if (pingObj is Component)
                {
                    pingObj = (pingObj as Component).gameObject;
                }

                EditorGUIUtility.PingObject(pingObj);
            }

            return(value);
        }
        /// <summary>
        /// Draws a objectpicker butter, in the given rect. This one is designed to look good on top of DrawDropZone().
        /// </summary>
        public static object ObjectPickerZone(Rect rect, object value, Type type, bool allowSceneObjects, int id)
        {
            var btnId        = GUIUtility.GetControlID(FocusType.Passive);
            var objectPicker = ObjectPicker.GetObjectPicker(type.FullName + "+" + btnId, type);
            var selectRect   = rect.AlignBottom(15).AlignCenter(45);
            var uObj         = value as UnityEngine.Object;

            selectRect.xMin = Mathf.Max(selectRect.xMin, rect.xMin);

            var hide = IsDragging || Event.current.type == EventType.Repaint && !rect.Contains(Event.current.mousePosition);

            if (hide)
            {
                GUIHelper.PushColor(new Color(0, 0, 0, 0));
                GUIHelper.PushGUIEnabled(false);
            }

            bool hideInspectorBtn = !hide && !(uObj);

            if (hideInspectorBtn)
            {
                GUIHelper.PushGUIEnabled(false);
                GUIHelper.PushColor(new Color(0, 0, 0, 0));
            }

            var inspectBtn = rect.AlignRight(14);

            inspectBtn.height = 14;
            SirenixEditorGUI.BeginDrawOpenInspector(inspectBtn, uObj, rect);
            SirenixEditorGUI.EndDrawOpenInspector(inspectBtn, uObj);

            if (hideInspectorBtn)
            {
                GUIHelper.PopColor();
                GUIHelper.PopGUIEnabled();
            }

            if (GUI.Button(selectRect, "select", SirenixGUIStyles.TagButton))
            {
                GUIHelper.RemoveFocusControl();
                objectPicker.ShowObjectPicker(allowSceneObjects, rect, false);
                Event.current.Use();
            }

            if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id)
            {
                objectPicker.ShowObjectPicker(allowSceneObjects, rect, false);
                Event.current.Use();
            }

            if (hide)
            {
                GUIHelper.PopColor();
                GUIHelper.PopGUIEnabled();
            }

            if (objectPicker.IsReadyToClaim)
            {
                GUIHelper.RequestRepaint();
                GUI.changed = true;
                var newValue = objectPicker.ClaimObject();
                Event.current.Use();
                return(newValue);
            }

            if (Event.current.keyCode == KeyCode.Delete && Event.current.type == EventType.KeyDown && EditorGUIUtility.keyboardControl == id)
            {
                Event.current.Use();
                GUI.changed = true;
                return(null);
            }

            if (uObj && Event.current.type == EventType.MouseUp && rect.Contains(Event.current.mousePosition) && EditorGUIUtility.hotControl == id && Event.current.button == 0)
            {
                EditorGUIUtility.PingObject(uObj);
            }

            return(value);
        }