示例#1
0
    void OnGUI()
    {
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        var defaultGUIColor          = GUI.color;
        var defaultGUIBackgrounColor = GUI.backgroundColor;

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.BeginVertical();

        // Quick start buttons
        DrawLine();
        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Start Selected"))
        {
            for (var i = 0; i < data.entries.Count; i++)
            {
                var entry = data.entries[i];
                if (!entry.selected)
                {
                    continue;
                }
                StartEntry(data.entries[i]);
            }
        }
        GUI.backgroundColor = defaultGUIBackgrounColor;

        DrawLine();
        GUI.backgroundColor = Color.red;
        if (GUILayout.Button("Stop All"))
        {
            BuildUtils.StopAll();
        }
        GUI.backgroundColor = defaultGUIBackgrounColor;

        DrawLine();
        if (GUILayout.Button("Add Entry"))
        {
            data.entries.Add(new Entry());
        }
        DrawLine();
        GUILayout.Space(10.0f);

        // Draw entries
        for (int i = 0; i < data.entries.Count; i++)
        {
            GUILayout.Space(5.0f);
            var entry = data.entries[i];

            GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
            {
                GUILayout.Space(5.0f);
                GUI.backgroundColor = entry.selected ? Color.green : defaultGUIBackgrounColor;
                if (GUILayout.Button("S", GUILayout.Width(20)))
                {
                    entry.selected = !entry.selected;
                }
                GUI.backgroundColor = defaultGUIBackgrounColor;

                entry.name = (BuildUtils.GameLoopMode)EditorGUILayout.EnumPopup(entry.name);

                GUILayout.Label("Count:", GUILayout.Width(40));
                entry.count = EditorGUILayout.IntField(entry.count, GUILayout.Width(40), GUILayout.ExpandWidth(false));

                GUI.backgroundColor = Color.yellow;
                if (GUILayout.Button("Start", GUILayout.Width(50)))
                {
                    StartEntry(entry);
                }
                GUI.backgroundColor = defaultGUIBackgrounColor;
                GUI.backgroundColor = entry.runInEditor ? Color.yellow : GUI.backgroundColor;
                GUI.backgroundColor = defaultGUIBackgrounColor;

                var runInEditor = GUILayout.Toggle(entry.runInEditor, "Editor", new GUIStyle("Button"), GUILayout.Width(50));
                if (runInEditor != entry.runInEditor)
                {
                    for (var j = 0; j < data.entries.Count; j++)
                    {
                        data.entries[j].runInEditor = false;
                    }
                    entry.runInEditor = runInEditor;
                }
                GUILayout.Space(5.0f);
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.FlexibleSpace();

        GUILayout.Space(10.0f);

        DrawLine();

        // Remove All Entries button
        GUILayout.BeginHorizontal();
        {
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Remove All Entries"))
            {
                data.entries.Clear();
            }
            GUI.backgroundColor = defaultGUIBackgrounColor;
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(10.0f);
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndScrollView();
    }