Garry's Mod Wiki

Garry's Mod Wiki

  Panel vgui.CreateFromTable( table metatable, Panel parent = nil, string name = nil )


Creates a panel from a table, used alongside vgui.RegisterFile and vgui.RegisterTable to efficiently define, register, and instantiate custom panels.


1 table metatable
Your PANEL table.
2 Panel parent = nil
Which panel to parent the newly created panel to.
3 string name = nil
Custom name of the created panel for scripting/debugging purposes. Can be retrieved with Panel:GetName.


1 Panel
The created panel, or nil if creation failed for whatever reason.


local CustomPanel = { Init = function( self ) self:SetSize( 200, 100 ) end, Paint = function( self, w, h ) surface.SetDrawColor( 0, 255, 0, 255 ) surface.DrawRect( 0, 0, w, h) end, } local my_custom_panel = vgui.RegisterTable( CustomPanel, "Panel" ) -- Register the panel class from a table local panel = vgui.CreateFromTable( my_custom_panel ) -- Create an instance of the panel panel:SetPos( 50, 50 )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...