コード例 #1
0
    public override void OnInspectorGUI()
    {
        GUIStyle centeredText = new GUIStyle(GUI.skin.GetStyle("Label"));

        centeredText.alignment = TextAnchor.MiddleCenter;

        custom = EditorGUILayout.ToggleLeft("Custom Editor", custom);
        if (custom)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Open Leaderboard"))
            {
                scr.OpenLeaderboard();
            }
            if (GUILayout.Button("Close Leaderboard"))
            {
                scr.CloseLeaderboard();
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            List <string> styles = new List <string>();
            for (int i = 0; i < scr.Styles.Count; i++)
            {
                styles.Add(scr.Styles[i].name);
            }
            selectedStyle     = styles.IndexOf(scr.SelectedStyle.name);
            selectedStyle     = EditorGUILayout.Popup(selectedStyle, styles.ToArray());
            scr.SelectedStyle = scr.Styles[selectedStyle];

            EditorGUILayout.Space();
            if (GUILayout.Button("Create Style"))
            {
                scr.Styles.Add(new Style());
            }
            for (int i = 0; i < scr.Styles.Count; i++)
            {
                Style style = scr.Styles[i];
                EditorGUILayout.BeginHorizontal();
                style.ShowInInspector = EditorGUILayout.BeginFoldoutHeaderGroup(style.ShowInInspector, style.name);
                if (GUILayout.Button("Remove Style", GUILayout.Width(175)))
                {
                    scr.Styles.Remove(style);
                }
                EditorGUILayout.EndHorizontal();
                if (style.ShowInInspector)
                {
                    EditorGUI.indentLevel++;
                    style.name        = EditorGUILayout.TextField("Name", style.name);
                    style.ShowPrefabs = EditorGUILayout.Foldout(style.ShowPrefabs, "Prefabs");
                    if (style.ShowPrefabs)
                    {
                        style.Prefab_Select = (GameObject)EditorGUILayout.ObjectField("Select view", style.Prefab_Select, typeof(GameObject), false);
                        style.Prefab_View   = (GameObject)EditorGUILayout.ObjectField("Board view", style.Prefab_View, typeof(GameObject), false);
                        style.Prefab_Button = (GameObject)EditorGUILayout.ObjectField("Button", style.Prefab_Button, typeof(GameObject), false);
                        style.Prefab_Entry  = (GameObject)EditorGUILayout.ObjectField("Entry", style.Prefab_Entry, typeof(GameObject), false);
                    }

                    style.ShowView = EditorGUILayout.Foldout(style.ShowView, "View Animation");
                    EditorGUI.indentLevel++;
                    if (style.ShowView)
                    {
                        GUILayout.BeginHorizontal();
                        EditorGUIUtility.labelWidth = 40;
                        style.startpos = EditorGUILayout.Vector2Field("Start:", style.startpos);
                        style.endPos   = EditorGUILayout.Vector2Field("End:", style.endPos);
                        EditorGUIUtility.labelWidth = default;
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        style.moveTime  = EditorGUILayout.FloatField(style.moveTime);
                        style.moveCurve = EditorGUILayout.CurveField(style.moveCurve);
                        GUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;

                    style.ShowButtons = EditorGUILayout.Foldout(style.ShowButtons, "Button Settings");
                    EditorGUI.indentLevel++;
                    if (style.ShowButtons)
                    {
                        EditorGUILayout.LabelField("Button names", centeredText);
                        GUILayout.BeginHorizontal();
                        style.AllName  = EditorGUILayout.TextField(style.AllName);
                        style.WeekName = EditorGUILayout.TextField(style.WeekName);
                        style.DayName  = EditorGUILayout.TextField(style.DayName);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        EditorGUIUtility.labelWidth = 80;
                        style.ActiveColor           = EditorGUILayout.ColorField("Selected:", style.ActiveColor);
                        style.InactiveColor         = EditorGUILayout.ColorField("Inactive:", style.InactiveColor);
                        EditorGUIUtility.labelWidth = default;
                        GUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;

                    style.ShowEntries = EditorGUILayout.Foldout(style.ShowEntries, "Entry Settings");
                    EditorGUI.indentLevel++;
                    if (style.ShowEntries)
                    {
                        style.OutputFormat = (outputForm)EditorGUILayout.EnumPopup("Score Format", style.OutputFormat);
                        EditorGUILayout.LabelField("Placement Colors", centeredText);
                        EditorGUILayout.BeginHorizontal();
                        style.GoldColor   = EditorGUILayout.ColorField(style.GoldColor);
                        style.SilverColor = EditorGUILayout.ColorField(style.SilverColor);
                        style.BronzeColor = EditorGUILayout.ColorField(style.BronzeColor);
                        style.BasicColor  = EditorGUILayout.ColorField(style.BasicColor);
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(scr);
            }
        }
        else
        {
            base.OnInspectorGUI();
        }
    }