コード例 #1
0
    void VertexToolbox()
    {
        GUI.color = VertexToolbarColor;

        EditorGUILayout.LabelField("Vertex Toolbox", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add", EditorStyles.miniButton))
        {
            plotter.AddSelection(plotter.CreateVertex());
        }

        if (GUILayout.Button("Pop", EditorStyles.miniButton))
        {
            plotter.DestroyVertex(plotter.LastVertex);
        }

        GUI.color = plotter.CurrentAction == HairyPlotterActions.VertexUvEdit ? ActiveUvEditorColor : VertexToolbarColor;

        if (GUILayout.Button("UV Editor", EditorStyles.miniButton))
        {
            if (plotter.CurrentAction == HairyPlotterActions.VertexUvEdit)
            {
                plotter.CurrentAction = HairyPlotterActions.None;
            }
            else
            {
                plotter.CurrentAction = HairyPlotterActions.VertexUvEdit;

                if (plotter.SelectedVertices.Count > 0)
                {
                    plotter.SetUvEditVertex(plotter.SelectedVertices.FirstOrDefault());
                }
            }
        }

        GUI.color = VertexToolbarColor;

        if (GUILayout.Button("Select All", EditorStyles.miniButton))
        {
            plotter.ClearVertexSelection();

            for (int i = 0; i < plotter.VertexCount; ++i)
            {
                plotter.AddSelection(i);
            }
        }

        GUI.color = VertexToolbarColor;

        if (plotter.CurrentAction == HairyPlotterActions.VertexClear)
        {
            if (GUILayout.Button("Yes!", EditorStyles.miniButton))
            {
                plotter.ClearVertices();
                plotter.CurrentAction = HairyPlotterActions.None;
            }

            if (GUILayout.Button("No!", EditorStyles.miniButton))
            {
                plotter.CurrentAction = HairyPlotterActions.None;
            }
        }
        else
        {
            if (GUILayout.Button("Delete All", EditorStyles.miniButton))
            {
                plotter.CurrentAction = HairyPlotterActions.VertexClear;
            }
        }

        if (plotter.CurrentAction == HairyPlotterActions.VertexClearUnused)
        {
            if (GUILayout.Button("Yes!", EditorStyles.miniButton))
            {
                foreach (HairyPlotterVertex vertex in plotter.UnusedVertices)
                {
                    plotter.DestroyVertex(vertex);
                }

                plotter.CurrentAction = HairyPlotterActions.None;
            }

            if (GUILayout.Button("No!", EditorStyles.miniButton))
            {
                plotter.CurrentAction = HairyPlotterActions.None;
            }
        }
        else
        {
            if (GUILayout.Button("Delete Unused", EditorStyles.miniButton))
            {
                plotter.CurrentAction = HairyPlotterActions.VertexClearUnused;
            }
        }

        EditorGUILayout.EndHorizontal();
        GUI.color = Color.white;
    }