Centering VGUI

Hello,

I have been trying to center my VGUI but it is not working correctly I used the [lua]panel:Center() [/lua] and it has been centering the top left corner only. If you know how to center the whole panel please post below.

Thanks!

Picture:

Make sure you set the size before :Center(). Also, what part are you trying to center?

I have set the size to 500x700 with [lua] DermaPanel:SetSize( 500, 700 ) [/lua] a few lines before if that is what you are talking about. I am trying to center the whole panel X and Y.

Post panel creation code pls



local cc_backpanel = vgui.Create("DFrame")
cc_backpanel:SetSize(700, 450)
cc_backpanel:Center()
cc_backpanel:MakePopup()


Creates a perfectly centered DFrame. Like I said, just put Center() after you SetSize()

This is my code to create the DFrame

[lua]
local servername = GetHostName( )
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:Center()
DermaPanel:SetSize( 500, 700) – Size of the frame
DermaPanel:SetTitle( "Welcome To " … servername … “!” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false )
DermaPanel:ShowCloseButton( true )
DermaPanel:SetBackgroundBlur( true )
DermaPanel:MakePopup() – Show the frame
DermaPanel.Paint = function()
surface.SetDrawColor( 50, 50, 50, 250 )
surface.DrawRect( 0, 0, 600, 500 )
surface.SetDrawColor( 255, 255, 255, 0 )
surface.DrawOutlinedRect( 0, 0, 600, 500 )
end
[/lua]

You didn’t listen. Read his post.

Woops… Sorry I did not read that right. Thanks for the help I appreciate it!