Exemple #1
0
            public void DrawItem()
            {
                bool hasLabel = this.labelName != null && (this.matchesSearchTerm || this.window.hasSearchTerm == false);

                if (hasLabel)
                {
                    bool isSelected = false, isChosen = false;
                    if (this.ChildNodes != null)
                    {
                        if (this.window.hideFoldoutLabels == false)
                        {
                            AllEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected);
                            {
                                if (this.matchesSearchTerm)
                                {
                                    AllEditorGUI.Foldout(true, this.label);
                                }
                                else
                                {
                                    this.IsVisible = AllEditorGUI.Foldout(this.IsVisible, this.label);
                                }
                            }
                            AllEditorGUI.EndMenuListItem();
                        }
                    }
                    else
                    {
                        AllEditorGUI.BeginMenuListItem(out isSelected, out isChosen, this.ForceSetSelected);
                        {
                            //if (this.drawHasNoEmptyConstructor)
                            //{
                            //    GUIHelper.PushGUIEnabled(false);
                            //}

                            // Properbly a type
                            if (this.isTypeNode && this.Type == typeof(NullType))
                            {
                                EditorGUILayout.LabelField(this.label, SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(this.label);
                            }

                            //if (this.drawHasNoEmptyConstructor)
                            //{
                            //    GUIHelper.PopGUIEnabled();
                            //}

                            if (this.drawHasNoEmptyConstructor)
                            {
                                var rect = GUILayoutUtility.GetLastRect();

                                rect.width -= 16;

                                EditorIcons.AlertTriangle.Draw(new Rect(rect.xMax, rect.yMin, 16, 16));

                                GUI.Label(rect, this.hasNoEmptyConstructorLabel, SirenixGUIStyles.RightAlignedGreyMiniLabel);
                                //isChosen = false;
                            }
                            //var rect = GUILayoutUtility.GetLastRect();
                            //if (this.isTypeNode && this.showNotSerializableLabel)
                            //{
                            //    GUI.Label(rect, isNotSerializableLabel, isSelected ? SirenixGUIStyles.RightAlignedWhiteMiniLabel : SirenixGUIStyles.RightAlignedGreyMiniLabel);
                            //}
                        }
                        AllEditorGUI.EndMenuListItem();
                    }

                    if (isSelected && Event.current.type == EventType.KeyDown)
                    {
                        if (Event.current.keyCode == KeyCode.RightArrow)
                        {
                            this.IsVisible = true;
                        }
                        else if (Event.current.keyCode == KeyCode.LeftArrow)
                        {
                            this.IsVisible = false;
                        }
                        else if (Event.current.keyCode == KeyCode.Return)
                        {
                            isChosen = true;
                        }
                    }

                    if (isChosen)
                    {
                        this.IsVisible = !this.IsVisible;

                        if (this.isTypeNode)
                        {
                            this.window.chosenType = this.Type;
                        }
                    }

                    this.ForceSetSelected = false;
                }

                if (this.labelName == null)
                {
                    this.IsVisible = true;
                }

                if (this.ChildNodes != null)
                {
                    if (this.matchesSearchTerm || AllEditorGUI.BeginFadeGroup(this, this.IsVisible))
                    {
                        if (hasLabel && !this.window.hideFoldoutLabels)
                        {
                            EditorGUI.indentLevel++;
                        }
                        for (int i = 0; i < this.ChildNodes.Count; i++)
                        {
                            this.ChildNodes[i].DrawItem();
                        }
                        if (hasLabel && !this.window.hideFoldoutLabels)
                        {
                            EditorGUI.indentLevel--;
                        }
                    }
                    if (this.matchesSearchTerm == false)
                    {
                        AllEditorGUI.EndFadeGroup();
                    }
                }
            }