public static void FoldSwitchableHeaderStart(ref bool enable, SerializedProperty toggle, ref bool foldout, string title, GUIStyle style = null, Texture icon = null, int height = 22, string tooltip = "", bool big = false)
        {
            if (style != null)
            {
                GUILayout.BeginVertical(style);
            }
            GUILayout.BeginHorizontal();

            if (enable)
            {
                if (GUILayout.Button(new GUIContent("  " + FGUI_Resources.GetFoldSimbol(foldout, 10, "►") + "  " + title, icon, tooltip), big ? FGUI_Resources.FoldStyleBig : FGUI_Resources.FoldStyle, GUILayout.Height(height)))
                {
                    foldout = !foldout;
                }
                EditorGUILayout.PropertyField(toggle, GUIContent.none, GUILayout.Width(16));
            }
            else
            {
                if (GUILayout.Button(new GUIContent("  " + title, icon, tooltip), big ? FGUI_Resources.FoldStyleBig : FGUI_Resources.FoldStyle, GUILayout.Height(height)))
                {
                    enable = true;
                }
                EditorGUILayout.PropertyField(toggle, GUIContent.none, GUILayout.Width(16));
            }

            GUILayout.EndHorizontal();
        }
 public static void FoldHeaderStart(ref bool foldout, GUIContent title, GUIStyle textStyle, GUIStyle vertStyle, Texture icon = null, int height = 22)
 {
     if (vertStyle != null)
     {
         GUILayout.BeginVertical(vertStyle);
     }
     if (GUILayout.Button(new GUIContent("  " + FGUI_Resources.GetFoldSimbol(foldout, 10, "►") + "  " + title.text, icon, title.tooltip), textStyle, GUILayout.Height(height)))
     {
         foldout = !foldout;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// GUILayout.EndVertical(); after foldout
 /// </summary>
 public static void FoldHeaderStart(ref bool foldout, string title, GUIStyle style, Texture icon = null, int height = 22)
 {
     if (style != null)
     {
         GUILayout.BeginVertical(style);
     }
     if (GUILayout.Button(new GUIContent("  " + FGUI_Resources.GetFoldSimbol(foldout, 10, "►") + "  " + title, icon), FGUI_Resources.FoldStyle, GUILayout.Height(height)))
     {
         foldout = !foldout;
     }
 }
        public static void HeaderBox(ref bool foldout, string title, bool frame, Texture icon = null, int height = 20, int iconsSize = 19, bool big = false)
        {
            if (frame)
            {
                EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyle);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
            }
            string f = FGUI_Resources.GetFoldSimbol(foldout);

            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));
            if (icon != null)
            {
                if (GUILayout.Button(new GUIContent(icon), EditorStyles.label, new GUILayoutOption[2] {
                    GUILayout.Width(iconsSize), GUILayout.Height(iconsSize)
                }))
                {
                    foldout = !foldout;
                }
            }
            if (GUILayout.Button(f + "     " + title + "     " + f, big ? FGUI_Resources.HeaderStyleBig : FGUI_Resources.HeaderStyle, GUILayout.Height(height)))
            {
                foldout = !foldout;
            }
            if (icon != null)
            {
                if (GUILayout.Button(new GUIContent(icon), EditorStyles.label, new GUILayoutOption[2] {
                    GUILayout.Width(iconsSize), GUILayout.Height(iconsSize)
                }))
                {
                    foldout = !foldout;
                }
            }
            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Color            c   = GUI.color;
            FPD_TabAttribute att = (FPD_TabAttribute)base.attribute;

            position.height = Attribute.IconSize + 4;

            if (icon == null)
            {
                if (string.IsNullOrEmpty(att.IconContent) == false)
                {
                    GUIContent gc = EditorGUIUtility.IconContent(att.IconContent);
                    if (gc != null)
                    {
                        if (gc.image != null)
                        {
                            icon = (Texture2D)gc.image;
                        }
                    }
                }

                if (string.IsNullOrEmpty(att.ResourcesIconPath) == false)
                {
                    icon = Resources.Load <Texture2D>(att.ResourcesIconPath);
                }
            }

            Rect pos = position; pos.y += 2; pos.height = 28 + att.IconSize - 24;

            GUI.color = new Color(att.R, att.G, att.B);
            GUI.BeginGroup(pos, FGUI_Resources.HeaderBoxStyle);
            GUI.EndGroup();
            GUI.color = c;

            if (!string.IsNullOrEmpty(att.FoldVariable))
            {
                if (foldProp == null)
                {
                    foldProp = property.serializedObject.FindProperty(att.FoldVariable);
                }
            }

            bool   folded = foldProp != null;
            string f      = folded ? FGUI_Resources.GetFoldSimbol(foldProp.boolValue) : "";
            string header = folded ? (f + "    " + Attribute.HeaderText + "    " + f) : Attribute.HeaderText;

            //if (folded) isUnfolded = foldProp.boolValue;

            if (icon != null)
            {
                if (GUI.Button(new Rect(pos.x + 4, pos.y + 3, att.IconSize, att.IconSize), new GUIContent(icon), EditorStyles.label))
                {
                    if (foldProp != null)
                    {
                        foldProp.boolValue = !foldProp.boolValue;
                    }
                    property.serializedObject.ApplyModifiedProperties();
                }
            }
            if (GUI.Button(pos, new GUIContent(header), FGUI_Resources.HeaderStyle))
            {
                if (foldProp != null)
                {
                    foldProp.boolValue = !foldProp.boolValue;
                }
                property.serializedObject.ApplyModifiedProperties();
            }
            if (icon != null)
            {
                if (GUI.Button(new Rect(pos.width - att.IconSize + 9, pos.y + 3, att.IconSize, att.IconSize), new GUIContent(icon), EditorStyles.label))
                {
                    if (foldProp != null)
                    {
                        foldProp.boolValue = !foldProp.boolValue;
                    }
                    property.serializedObject.ApplyModifiedProperties();
                }
            }
        }