Garry's Mod Wiki

DImage:SetImage

DImage:SetImage( string strImage, string strBackup = "nil" )

Description

Sets the image to load into the frame. If the first image can't be loaded and strBackup is set, that image will be loaded instead.

This eventually calls DImage:SetMaterial.

Arguments

1 string strImage
The path of the image to load. When no file extension is supplied the VMT file extension is used.
2 string strBackup = "nil"
The path of the backup image.

Example

Creates a frame with a map of de_inferno inside, with the default avatar image loaded as a backup.

-- Frame MainFrame = vgui.Create( "DFrame" ) MainFrame:SetSize( 300, 300 ) MainFrame:Center() MainFrame:SetTitle( "Map of de_inferno" ) -- Map of de_inferno (requires CS:S) local css_map = vgui.Create( "DImage", MainFrame ) css_map:SetPos( 25, 40 ) css_map:SetSize( 250, 250 ) -- Set image to de_inferno map -- If it can't be loaded, load the [?] avatar image instead css_map:SetImage("overviews/de_inferno", "vgui/avatar_default")
Output: If CS:S is mounted then the left image is shown, otherwise the right image is shown.

Page Links


Special Pages


Wikis

?

Render Time: 25ms

DB GetPage 2
Generate Html 3
SaveChanges (1) 11
Render Body 0
Render Sidebar 6