Return to Snippet

Revision: 64281
at July 18, 2013 23:08 by Solipsist


Updated Code
public static void DrawRectangle(Rect rect, Color color, float alpha = 0f)
{
    Texture2D texture = new Texture2D(1, 1);
    color.a = alpha;
    texture.SetPixel(0, 0, color);
    texture.wrapMode = TextureWrapMode.Repeat;
    texture.Apply();
    GUI.DrawTexture(rect, texture);
}

Revision: 64280
at July 18, 2013 23:07 by Solipsist


Initial Code
public static void DrawRectangle(Rect rect, Color color, float alpha = 0f)
    {
        Texture2D texture = new Texture2D(1, 1);
        color.a = alpha;
        texture.SetPixel(0, 0, color);
        texture.wrapMode = TextureWrapMode.Repeat;
        texture.Apply();
        GUI.DrawTexture(rect, texture);
    }

Initial URL


Initial Description
Draw rectangle with alpha (Unity GUI)

Initial Title
Rectangle with alpha (Unity)

Initial Tags


Initial Language
C#