Description
Material is a VGUI element that renders a VMT material.
View source
Parent
Derives methods, etc not listed on this page from Button.
Methods
Sets the alpha value of the Material panel.
Sets the material used by the panel.
If the material is not showing up as the correct size, try setting the Material panel's AutoSize variable to false
Example
Creates a Material panel with TV static under a DModelPanel with a spinning Garry's Mod logo model.
BGPanel
= vgui.
Create(
"DPanel")
BGPanel:
SetSize(
400,
400)
BGPanel:
Center()
BGPanel:
SetBackgroundColor(
Color(
0,
0,
0,
255))
local mat
= vgui.
Create(
"Material", BGPanel)
mat:
SetPos(
10,
10)
mat:
SetSize(
380,
380)
mat:
SetMaterial(
"effects/tvscreen_noise002a")
mat.AutoSize
= false
local mdl
= vgui.
Create(
"DModelPanel", BGPanel)
mdl:
SetPos(
10,
10)
mdl:
SetSize(
380,
380)
mdl:
SetModel(
"models/maxofs2d/logo_gmod_b.mdl")
mdl:
SetCamPos(
Vector(
240,
0,
0))
mdl:
SetLookAt(
Vector(
0,
0,
0))
mdl:
SetFOV(
40)
function mdl:
LayoutEntity(ent)
ent:
SetAngles(
Angle(
0,
RealTime()
*100,
0))
endOutput: Example
Creates a custom material (using existing textures) of a Portal background with scrolling scan lines, and then displays that material in a Material panel in the center of the screen.
BGPanel
= vgui.
Create(
"DPanel")
BGPanel:
SetSize(
720,
480)
BGPanel:
Center()
BGPanel:
SetBackgroundColor(
Color(
0,
0,
0,
255))
local matdata
= {
["$basetexture"]="vgui/appchooser/background_portal_widescreen",
["$texture2"]="dev/dev_scanline",
["Proxies"]={
["TextureScroll"]={
["texturescrollvar"]="$texture2transform",
["texturescrollrate"]=.
06,
["texturescrollangle"]=-90
}
}
}
local portal_scanlines
= CreateMaterial(
"PortalScanlines",
"UnlitTwoTexture", matdata)
portal_scanlines:
Recompute()
local mat
= vgui.
Create(
"Material", BGPanel)
mat:
SetPos(
5,
5)
mat:
SetSize(
710,
470)
mat.Material
= portal_scanlines
mat.AutoSize
= falseOutput: