This article's documentation is for anything that uses the Source engine. Click here for more information.

Env texturetoggle: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Compare with)
mNo edit summary
 
(23 intermediate revisions by 12 users not shown)
Line 1: Line 1:
__NOTOC__
{{LanguageBar}}
[[File:env_texturetoggle.png|left|link=]]
[[File:env_texturetoggle.png|left|link=]]
{{CD|CTextureToggle|file1=env_texturetoggle.cpp}}
{{This is a|point entity|name=env_texturetoggle}}
It allows you to change the textures on brush entities or overlays.
{{clr}}
== Entity Description ==
<syntaxhighlight lang=php style="float:right; background:none">
LightmappedGeneric
{
  $basetexture "path/to/a/VTF/file/with/multiple/frames"
  Proxies
  {
    ToggleTexture
    {
      ToggleTextureVar        $basetexture
      ToggleTextureFrameNumVar $frame
    }
  }
}
</syntaxhighlight>
In order for <code>env_texturetoggle</code> to work properly, your [[info_overlay|overlay]] or at least one face of your [[brush]] must use a [[VMT]] material with the <code>[[List Of Material Proxies#Entity integration|ToggleTexture</code> proxy]] defined and pointing to an animated [[VTF]] file with at least two frames.


{{base point|env_texturetoggle}} It allows you to change the textures on other brush-built entities.
Such a VMT file could look like the one on the right.


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 [[List Of Material Proxies#Texture manipulation|''ToggleTexture'' proxy]] defined and pointing to an Animated [[VTF]] file with at least two frames.
{{Example| If we have a brush entity named <code>brush</code> and an env_texturetoggle named <code>toggle</code> whose target brush is <code>brush</code>, then we can use any of the following outputs on a [[func_button]] to toggle the texture for the <code>brush</code>. The second and third output have the same effect.}}
:{| {{OutputsTable}}
|+ '''Inputs to toggle textures'''
| [[File:io11.png]] || OnPressed || toggle || IncrementTextureIndex || || 0 || No
|-
| [[File:io11.png]] || OnPressed || toggle || SetTextureIndex || <n> || 0 || No
|}


Compare this with the [[material_modify_control]] entity that can modify any parameter of a material globally.
{{note|If a brush has multiple textures with multiple frames, an output will affect all of these textures.}}
{{clr}}
{{codenote|An entity's texture frame can be set via code using the {{codelink|SetTextureFrameIndex()}} function.}}
{{bug|tested={{portal}}|Identical textures on visible unnamed overlays may also be impacted.}}


== Keyvalues ==
== Keyvalues ==
{{KV|Target Brush(es).|target_destination|Name of the brushes or [[info_overlay]]s.}}
{{KV Targetname}}
{{KV Targetname}}
{{KV|Target Brush(es)|intn=target|target_destination|Name of the [[brush entity|brush entities]] or [[overlay]]s. All <code>ToggleTexture</code> materials on all entities (including sprites) matching the targetname will be affected.}}


== Inputs ==
== Inputs ==
{{IO|IncrementTextureIndex|Increments target brush's current texture frame by one.}}
{{I|IncrementTextureIndex|param=void|Increments target brush's current texture frame by one. In other words: switches to the ''next'' texture.}}
{{IO|SetTextureIndex|Sets target brush's texture frame to the specified index.|param=integer}}
{{I|SetTextureIndex|param=integer|Sets target brush's texture frame to the specified index.}}
{{I Targetname}}
:{{note|While this parameter takes an integer, it writes to an [[byte|unsigned char]] without any bounds checking. Values above 255 or below 0 will {{w|Integer overflow|overflow}}.}}


== Outputs ==
== See also ==
{{O Targetname}}
* {{ent|material_modify_control}}
[[Category:Source base entities]]

Latest revision as of 05:26, 22 July 2025

English (en)中文 (zh)Translate (Translate)
Env texturetoggle.png
C++ Class hierarchy
CTextureToggle
CPointEntity
CBaseEntity
C++ env_texturetoggle.cpp

env_texturetoggle is a point entity available in all Source 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.

PlacementTip.pngExample: If we have a brush entity named 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
Io11.png OnPressed toggle IncrementTextureIndex 0 No
Io11.png OnPressed toggle SetTextureIndex <n> 0 No
Note.pngNote:If a brush has multiple textures with multiple frames, an output will affect all of these textures.
Cpp.pngCode:An entity's texture frame can be set via code using the SetTextureFrameIndex() function.
Icon-Bug.pngBug:Identical textures on visible unnamed overlays may also be impacted.  (tested in: Portal)

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
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 <integerRedirectInput/integer>
Sets target brush's texture frame to the specified index.
Note.pngNote:While this parameter takes an integer, it writes to an unsigned char without any bounds checking. Values above 255 or below 0 will Wikipedia icon overflow.

See also