示例#1
0
        static Vector2 AlignmentOffset(GuiAlignment alignment, float width, float height)
        {
            switch (alignment)
            {
            case GuiAlignment.TopLeft:
                return(new Vector2(width > 0f ? 0f : -width, height > 0f ? -height : 0f));

            case GuiAlignment.TopCenter:
                return(new Vector2(-width * 0.5f, height > 0f ? -height : 0f));

            case GuiAlignment.TopRight:
                return(new Vector2(width > 0f ? -width : 0f, height > 0f ? -height : 0f));

            case GuiAlignment.CenterLeft:
                return(new Vector2(width > 0f ? 0f : -width, -height * 0.5f));

            case GuiAlignment.Center:
                return(new Vector2(-width * 0.5f, -height * 0.5f));

            case GuiAlignment.CenterRight:
                return(new Vector2(width > 0f ? -width : 0f, -height * 0.5f));

            case GuiAlignment.BottomLeft:
                return(new Vector2(width > 0f ? 0f : -width, height > 0f ? 0f : -height));

            case GuiAlignment.BottomCenter:
                return(new Vector2(-width * 0.5f, height > 0f ? 0f : -height));

            case GuiAlignment.BottomRight:
                return(new Vector2(width > 0f ? -width : 0f, height > 0f ? 0f : -height));

            default:
                return(Vector2.zero);
            }
        }
 static Vector2 AlignmentOffset(GuiAlignment alignment, float width, float height)
 {
     switch (alignment) {
     case GuiAlignment.TopLeft:
         return new Vector2 (width > 0f ? 0f : -width, height > 0f ? -height : 0f);
     case GuiAlignment.TopCenter:
         return new Vector2 (-width * 0.5f, height > 0f ? -height : 0f);
     case GuiAlignment.TopRight:
         return new Vector2 (width > 0f ? -width : 0f, height > 0f ? -height : 0f);
     case GuiAlignment.CenterLeft:
         return new Vector2 (width > 0f ? 0f : -width, -height * 0.5f);
     case GuiAlignment.Center:
         return new Vector2 (-width * 0.5f, -height * 0.5f);
     case GuiAlignment.CenterRight:
         return new Vector2 (width > 0f ? -width : 0f, -height * 0.5f);
     case GuiAlignment.BottomLeft:
         return new Vector2 (width > 0f ? 0f : -width, height > 0f ? 0f : -height);
     case GuiAlignment.BottomCenter:
         return new Vector2 (-width * 0.5f, height > 0f ? 0f : -height);
     case GuiAlignment.BottomRight:
         return new Vector2 (width > 0f ? -width : 0f, height > 0f ? 0f : -height);
     default:
         return Vector2.zero;
     }
 }