Example #1
0
        void OnGUI()
        {
            if (surfaceEditor == null || csgModel == null)
            {
                // Link to face tool has been lost, so attempt to reacquire
                CSGModel[] csgModels = FindObjectsOfType <CSGModel>();

                // Build the first csg model that is currently being edited
                for (int i = 0; i < csgModels.Length; i++)
                {
                    if (csgModels[i].EditMode)
                    {
                        csgModel      = csgModels[i];
                        surfaceEditor = csgModels[i].GetTool(MainMode.Face) as SurfaceEditor;
                        break;
                    }
                }

                // If it's still null
                if (surfaceEditor == null || csgModel == null)
                {
                    GUILayout.Label("No active CSG Model");
                    return;
                }
            }

            GUILayout.Label("Set Vertex Colors", SabreGUILayout.GetTitleStyle());

            Color sourceColor = surfaceEditor.GetColor();

            Color newColor = EditorGUILayout.ColorField(sourceColor);

            if (newColor != sourceColor)
            {
                surfaceEditor.SetSelectionColor(newColor);
            }

            // Preset color buttons
            GUILayout.BeginHorizontal();
            for (int i = 0; i < PRESET_COLORS.Length; i++)
            {
                if (SabreGUILayout.ColorButton(PRESET_COLORS[i]))
                {
                    surfaceEditor.SetSelectionColor(PRESET_COLORS[i]);
                }
            }
            GUILayout.EndHorizontal();
        }