Material/SetMaterial

From Garry's Mod
Jump to: navigation, search
 Material:SetMaterial( )

Contents

DescriptionPanelFunc

Sets the material used by the panel.

NOTE

If the material is not showing up as the correct size, try setting the Material panel's AutoSize variable to false

Arguments

string matname

The file path of the material to set (relative to "garrysmod/materials/").

Examples

Example

Creates a Material panel and sets the material to a screen space effect.

-- Black background panel
BGPanel = vgui.Create("DPanel")
BGPanel:SetSize(200, 200)
BGPanel:Center()
BGPanel:SetBackgroundColor(Color(0, 0, 0, 255))
		
local mat = vgui.Create("Material", BGPanel)
mat:SetPos(5, 5)
mat:SetSize(190, 190)

-- It's not really good to use a models material for VGUI drawing
-- But it looks good enough for a quick demo
mat:SetMaterial("models/screenspace")

-- Stretch to fit
mat.AutoSize = false

Output:



Material SetMaterial example1.jpg
Personal tools
Navigation