Garry's Mod Wiki

SpawnIcon

Description

A "spawn icon" displays an image for the given model path. It is mostly used in the Spawn Menu (q). It uses ModelImage internally.

View source

Parent

Derives methods, etc not listed on this page from DButton.

Methods

string SpawnIcon:GetBodyGroup()
Returns the currently set body groups of the spawn icon. This is set by SpawnIcon:SetBodyGroup.
string SpawnIcon:GetModelName()
Returns the currently set model name. This is set by SpawnIcon:SetModelName.
number SpawnIcon:GetSkinID()
Returns the currently set skin of the spawnicon. This is set by SpawnIcon:SetSkinID.
SpawnIcon:OpenMenu()
Called when right clicked on the SpawnIcon. It will not be called if there is a selection (Panel:GetSelectionCanvas), in which case SANDBOX:SpawnlistOpenGenericMenu is called.
SpawnIcon:SetBodyGroup( number bodygroup, number value )
This is used internally - although you're able to use it you probably shouldn't. This is done automatically by SpawnIcon. You do not need to call this. Doing so may cause unforeseen consequences. Sets the bodygroups, so it can be retrieved with SpawnIcon:GetBodyGroup. Use Panel:SetModel instead.
SpawnIcon:SetModelName( string mdl )
This is used internally - although you're able to use it you probably shouldn't. This is done automatically by SpawnIcon. You do not need to call this. Doing so may cause unforeseen consequences. Sets the model name, so it can be retrieved with SpawnIcon:GetModelName. Use Panel:SetModel instead.
SpawnIcon:SetSkinID( number skin )
This is used internally - although you're able to use it you probably shouldn't. This is done automatically by SpawnIcon. You do not need to call this. Doing so may cause unforeseen consequences. Sets the skin id of the spawn icon, so it can be retrieved with SpawnIcon:GetSkinID. Use Panel:SetModel instead.

Example

Creates a DFrame with a SpawnIcon inside.

local Panel = vgui.Create( "DFrame" ) -- Main Frame Panel:SetPos( 200, 200 ) Panel:SetSize( 200, 200 ) Panel:SetTitle( "Spawn Icon Test" ) Panel:MakePopup() local SpawnI = vgui.Create( "SpawnIcon" , Panel ) -- SpawnIcon SpawnI:SetPos( 75, 75 ) SpawnI:SetModel( "models/props_borealis/bluebarrel001.mdl" ) -- Model we want for this spawn icon