Exemplo n.º 1
0
    public static void ConvertRectWithAlign(ref Rect rect, DrawAlign align)
    {
        switch (align)
        {
        case DrawAlign.TOPLEFT:
        {
            rect.x += rect.width / 2;
            rect.y += rect.height / 2;
        }; break;

        case DrawAlign.TOP:
        {
            rect.y += rect.height / 2;
        }; break;

        case DrawAlign.TOPRIGHT:
        {
            rect.x -= rect.width / 2;
            rect.y += rect.height / 2;
        }; break;

        case DrawAlign.LEFT:
        {
            rect.x += rect.width / 2;
        }; break;

        case DrawAlign.CENTER:
        {
            // 什么都不做
        }; break;

        case DrawAlign.RIGHT:
        {
            rect.x -= rect.width / 2;
        }; break;

        case DrawAlign.BOTTOM:
        {
            rect.y -= rect.height / 2;
        }; break;

        case DrawAlign.BOTTOMLEFT:
        {
            rect.x += rect.width / 2;
            rect.y -= rect.height / 2;
        }; break;

        case DrawAlign.BOTTOMRIGHT:
        {
            rect.x -= rect.width / 2;
            rect.y -= rect.height / 2;
        }; break;
        }
    }
Exemplo n.º 2
0
    public static void DrawLabel(Vector2 pos, string lb, Color color, DrawAlign align = DrawAlign.CENTER, bool shadow = false)
    {
        Vector2 size = EditorUtil.GetStringSize(lb);

        tmpRect.width  = size.x;
        tmpRect.height = size.y;
        tmpRect.center = pos;
        ConvertRectWithAlign(ref tmpRect, align);

        if (shadow)
        {
            using (new GUIColor(Color.black))
            {
                tmpRect.center += Vector2.one;
                GUI.Label(tmpRect, lb);
                tmpRect.center -= Vector2.one;
            }
        }

        using (new GUIColor(color))
        {
            GUI.Label(tmpRect, lb);
        }
    }
Exemplo n.º 3
0
 internal void DrawBorderAlign(DrawAlign Align)
 {
     this.DrawType    = Align;
     havetoDrawBorder = true;
     this.Invalidate();
 }
Exemplo n.º 4
0
    public static void DrawTexture(Vector2 pos, int width, int height, Texture2D tex, Rect tile, Color color, DrawAlign align = DrawAlign.CENTER)
    {
        tmpRect.width  = width;
        tmpRect.height = height;
        tmpRect.center = pos;

        ConvertRectWithAlign(ref tmpRect, align);
        using (new GUIColor(color))
        {
            GUI.DrawTextureWithTexCoords(tmpRect, tex, tile, true);
        }
    }