Beispiel #1
0
        static public bool DrawHeader(string text, bool state, bool ShowToggle = false, bool ToggleState = false, fnOnToggled OnToggle = null, string HelpURL = default(string), Color disabledColor = default(Color), bool allowCollapsing = true)
        {
            GUIStyle Style = new GUIStyle(EditorStyles.foldout);

            Style.richText = true;
            EditorStyles.foldout.richText = true;
            if (state)
            {
                GUI.backgroundColor = DarkGray;
                GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(1));
                GUILayout.BeginHorizontal();
                if (!string.IsNullOrEmpty(text))
                {
                    if (allowCollapsing)
                    {
                        state = GUILayout.Toggle(state, text, Style, GUILayout.ExpandWidth(true));
                    }
                    else
                    {
                        GUILayout.Label(text, GUILayout.ExpandWidth(true));
                    }
                }

                if (!string.IsNullOrEmpty(HelpURL))
                {
                    if (GUILayout.Button(Icon_Help, EditorStyles.label, GUILayout.ExpandWidth(false)))
                    {
                        Application.OpenURL(HelpURL);
                    }
                }
                if (ShowToggle)
                {
                    GUI.changed = false;
                    bool newBool = GUILayout.Toggle(ToggleState, "", "OL Toggle", GUILayout.ExpandWidth(false));
                    if (GUI.changed && OnToggle != null)
                    {
                        OnToggle(newBool);
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(2);

                GUI.backgroundColor = Color.white;
            }
            else
            {
                if (ShowToggle && !ToggleState)
                {
                    GUI.color = disabledColor;
                }

                GUILayout.BeginHorizontal("Box");
                //GUILayout.BeginHorizontal(EditorStyles.toolbar);
                state = GUILayout.Toggle(state, text, Style, GUILayout.ExpandWidth(true));
                if (ShowToggle)
                {
                    GUI.changed = false;
                    bool newBool = GUILayout.Toggle(ToggleState, "", "OL Toggle", GUILayout.ExpandWidth(false));
                    if (GUI.changed && OnToggle != null)
                    {
                        OnToggle(newBool);
                    }
                }
                GUILayout.EndHorizontal();
                GUI.color = GUITools.White;
            }
            return(state);
        }
Beispiel #2
0
        static public bool DrawHeader(string text, string key, bool ShowToggle = false, bool ToggleState = false, fnOnToggled OnToggle = null, string HelpURL = default(string), Color disabledColor = default(Color))
        {
            bool state = EditorPrefs.GetBool(key, false);

            bool newState = DrawHeader(text, state, ShowToggle, ToggleState, OnToggle, HelpURL, disabledColor);

            if (state != newState)
            {
                EditorPrefs.SetBool(key, newState);
            }
            return(newState);
        }