Env texturetoggle: Difference between revisions
Jump to navigation
Jump to search
Example: If we have a brush entity named
Note:If a brush has multiple textures with multiple frames, an output will affect all of these textures.
Code:An entity's texture frame can be set via code using the SetTextureFrameIndex function.
(changing it via addoutput doesn't work in portal, this entity also immediately updates the network variable which addoutput doesn't do) |
SirYodaJedi (talk | contribs) |
||
Line 35: | Line 35: | ||
{{note|If a brush has multiple textures with multiple frames, an output will affect all of these textures.}} | {{note|If a brush has multiple textures with multiple frames, an output will affect all of these textures.}} | ||
{{codenote|An entity's texture frame can be set via code using the [[SetTextureFrameIndex]] function.}} | {{codenote|An entity's texture frame can be set via code using the [[SetTextureFrameIndex]] function.}} | ||
{{bug|tested={{portal}}|Identical textures on visible unnamed overlays may also be impacted.}} | |||
== Keyvalues == | == Keyvalues == |
Revision as of 09:57, 6 May 2025

![]() |
---|
CTextureToggle |
![]() |
env_texturetoggle
is a point entity available in all Source games.
It allows you to change the textures on brush entities or overlays.
Entity Description
LightmappedGeneric
{
$basetexture "path/to/a/VTF/file/with/multiple/frames"
Proxies
{
ToggleTexture
{
ToggleTextureVar $basetexture
ToggleTextureFrameNumVar $frame
}
}
}
In order for env_texturetoggle
to work properly, your overlay or at least one face of your brush must use a VMT material with the ToggleTexture
proxy defined and pointing to an animated VTF file with at least two frames.
Such a VMT file could look like the one on the right.

brush
and an env_texturetoggle named toggle
whose target brush is brush
, then we can use any of the following outputs on a func_button to toggle the texture for the brush
. The second and third output have the same effect.My Output Target Entity Target Input Parameter Delay Only Once Inputs to toggle textures OnPressed toggle IncrementTextureIndex 0 No OnPressed toggle SetTextureIndex <n> 0 No


Keyvalues
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Target Brush(es) (target) <targetname>
- Name of the brush entities or overlays. All
ToggleTexture
materials on all entities (including sprites) matching the targetname will be affected.
Inputs
- IncrementTextureIndex <void>
- Increments target brush's current texture frame by one. In other words: switches to the next texture.
- SetTextureIndex <integer >
- Sets target brush's texture frame to the specified index.
Note:While this parameter takes an integer, it writes to an unsigned char without any bounds checking. Values above 255 or below 0 will
overflow.