Exemplo n.º 1
0
	void OnGUI()
	{		
		GUILayout.BeginHorizontal(EditorStyles.toolbar);

			if(mode == VertexPainterMode.Color)	GUI.backgroundColor = Color.gray;

			if(GUILayout.Button("Colors", EditorStyles.toolbarButton))
			{
				colorName = pb_ColorUtil.GetColorName(color);
				mode = VertexPainterMode.Color;
			}

			GUI.backgroundColor = mode == VertexPainterMode.Texture ? Color.gray : Color.white;
			if(GUILayout.Button("Textures", EditorStyles.toolbarButton))
			{
				switch(GetIndex(color))
				{
					case 0:	
						color = Color.red;
						break;
					case 1:	
						color = Color.green;
						break;
					case 2:	
						color = Color.blue;
						break;
					case 3:	
						color = Color.black;
						break;
				}
				mode = VertexPainterMode.Texture;
			}

			GUI.backgroundColor = Color.white;
		GUILayout.EndHorizontal();

		scroll = EditorGUILayout.BeginScrollView(scroll);


		lockhandleToCenter = EditorWindow.focusedWindow == this;

		/**
		 * BRUSH SETTINGS
		 */

		enabled = EditorGUILayout.Toggle("Enabled", enabled);
	
		EditorGUI.BeginChangeCheck();
			
			brushSize = EditorGUILayout.Slider(gc_BrushSize, brushSize, .01f, BRUSH_SIZE_MAX);
			brushOpacity = EditorGUILayout.Slider(gc_BrushOpacity, brushOpacity, .01f, 1f);
			brushStrength = EditorGUILayout.Slider(gc_BrushStrength, brushStrength, .01f, 1f);

		if(EditorGUI.EndChangeCheck())
			SceneView.RepaintAll();


		GUILayout.Space(6);
		pb_GUI_Utility.DrawSeparator(2, pb_Constant.ProBuilderLightGray);
		GUILayout.Space(6);

		/**
		 * COLOR / TEXTURE SPECIFIC SETTINGS
		 */

		if(mode == VertexPainterMode.Color)
		{
			ColorGUI();
		}
		else
		{
			GUILayout.BeginHorizontal();
			int max = (Screen.width - 20) / 4;

			// Only allow 4
			for(int i = 0; i < (int)Mathf.Min(textures.Length, 4); i++)
			{
				if( GUILayout.Button(i < textures.Length ? textures[i] : null, EditorStyles.label, GUILayout.MaxWidth(max), GUILayout.MaxHeight(max)) )
				{
					color.r = i == 0 ? 1f : 0f;
					color.g = i == 1 ? 1f : 0f;
					color.b = i == 2 ? 1f : 0f;
					color.a = i == 3 ? 1f : 0f;
				}

				if( i < textures.Length && i == GetIndex(color) )
				{
					Rect r = GUILayoutUtility.GetLastRect();

					r.y += r.height + 4;
					r.width -= 4f;
					r.x += 2f;
					r.height = 6f;

					pb_GUI_Utility.DrawSolidColor(r, Color.green);
				}
			}
			GUILayout.EndHorizontal();

			GUILayout.Space(6);
		}

		GUILayout.Space(6);

		helpFoldout = EditorGUILayout.Foldout(helpFoldout, "Help!");

		if( helpFoldout )
		{
			EditorGUILayout.HelpBox(@"If you're not seeing anything happen on your ProBuilder object, make sure that you're using a shader that supports vertex colors.  The ProBuilder default material provides support for colored vertices, and the included `Diffuse Texture Blend` material supports blending multiple textures together.  You can use the shaders from either of these on new Materials that you create to enable vertex color support.", MessageType.Info);

			if(GUILayout.Button("Show me the Vertex Color Shader"))
			{
				Shader shader = Shader.Find("ProBuilder/Diffuse Vertex Color");
				if(shader != null)
					EditorGUIUtility.PingObject(shader);
				else
					Debug.LogWarning("Couldn't find default ProBuilder shader: \"Diffuse Vertex Color\"");
			}

			if(GUILayout.Button("Show me the Texture Blend Shader"))
			{
				Shader shader = Shader.Find("ProBuilder/Diffuse Texture Blend");
				if(shader != null)
					EditorGUIUtility.PingObject(shader);
				else
					Debug.LogWarning("Couldn't find default ProBuilder shader: \"Diffuse Texture Blend\"");
			}
		}

		EditorGUILayout.EndScrollView();
	}
Exemplo n.º 2
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal(EditorStyles.toolbar);

        if (mode == VertexPainterMode.Color)
        {
            GUI.backgroundColor = Color.gray;
        }

        if (GUILayout.Button("Colors", EditorStyles.toolbarButton))
        {
            colorName = pb_ColorUtil.GetColorName(color);
            mode      = VertexPainterMode.Color;
        }

        GUI.backgroundColor = mode == VertexPainterMode.Texture ? Color.gray : Color.white;
        if (GUILayout.Button("Textures", EditorStyles.toolbarButton))
        {
            switch (GetIndex(color))
            {
            case 0:
                color = Color.red;
                break;

            case 1:
                color = Color.green;
                break;

            case 2:
                color = Color.blue;
                break;

            case 3:
                color = Color.black;
                break;
            }
            mode = VertexPainterMode.Texture;
        }

        GUI.backgroundColor = Color.white;
        GUILayout.EndHorizontal();

        scroll = EditorGUILayout.BeginScrollView(scroll);


        lockhandleToCenter = EditorWindow.focusedWindow == this;

        /**
         * BRUSH SETTINGS
         */

        enabled = EditorGUILayout.Toggle("Enabled", enabled);

        EditorGUI.BeginChangeCheck();

        brushSize     = EditorGUILayout.Slider(gc_BrushSize, brushSize, .01f, BRUSH_SIZE_MAX);
        brushOpacity  = EditorGUILayout.Slider(gc_BrushOpacity, brushOpacity, .01f, 1f);
        brushStrength = EditorGUILayout.Slider(gc_BrushStrength, brushStrength, .01f, 1f);

        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }


        GUILayout.Space(6);
        pb_GUI_Utility.DrawSeparator(2, pb_Constant.ProBuilderLightGray);
        GUILayout.Space(6);

        /**
         * COLOR / TEXTURE SPECIFIC SETTINGS
         */

        if (mode == VertexPainterMode.Color)
        {
            ColorGUI();
        }
        else
        {
            GUILayout.BeginHorizontal();
            int max = (Screen.width - 20) / 4;

            // Only allow 4
            for (int i = 0; i < (int)Mathf.Min(textures.Length, 4); i++)
            {
                if (GUILayout.Button(i < textures.Length ? textures[i] : null, EditorStyles.label, GUILayout.MaxWidth(max), GUILayout.MaxHeight(max)))
                {
                    color.r = i == 0 ? 1f : 0f;
                    color.g = i == 1 ? 1f : 0f;
                    color.b = i == 2 ? 1f : 0f;
                    color.a = i == 3 ? 1f : 0f;
                }

                if (i < textures.Length && i == GetIndex(color))
                {
                    Rect r = GUILayoutUtility.GetLastRect();

                    r.y     += r.height + 4;
                    r.width -= 4f;
                    r.x     += 2f;
                    r.height = 6f;

                    pb_GUI_Utility.DrawSolidColor(r, Color.green);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(6);
        }

        GUILayout.Space(6);

        helpFoldout = EditorGUILayout.Foldout(helpFoldout, "Help!");

        if (helpFoldout)
        {
            EditorGUILayout.HelpBox(@"If you're not seeing anything happen on your ProBuilder object, make sure that you're using a shader that supports vertex colors.  The ProBuilder default material provides support for colored vertices, and the included `Diffuse Texture Blend` material supports blending multiple textures together.  You can use the shaders from either of these on new Materials that you create to enable vertex color support.", MessageType.Info);

            if (GUILayout.Button("Show me the Vertex Color Shader"))
            {
                Shader shader = Shader.Find("ProBuilder/Diffuse Vertex Color");
                if (shader != null)
                {
                    EditorGUIUtility.PingObject(shader);
                }
                else
                {
                    Debug.LogWarning("Couldn't find default ProBuilder shader: \"Diffuse Vertex Color\"");
                }
            }

            if (GUILayout.Button("Show me the Texture Blend Shader"))
            {
                Shader shader = Shader.Find("ProBuilder/Diffuse Texture Blend");
                if (shader != null)
                {
                    EditorGUIUtility.PingObject(shader);
                }
                else
                {
                    Debug.LogWarning("Couldn't find default ProBuilder shader: \"Diffuse Texture Blend\"");
                }
            }
        }

        EditorGUILayout.EndScrollView();
    }