Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

RenderTexture

Namespace: UnityEngine

/

Inherits from: Texture

Description

Render textures are textures that can be rendered to.

They can be used to implement image based rendering effects, dynamic shadows, projectors, reflections or surveillance cameras.

All rendering goes into the active RenderTexture (active class property). If the active RenderTexture is null everything is rendered to the main window.

For short-lived temporary render textures, use GetTemporary and ReleaseTemporary functions. These are most often useful in image post processing effects.

Note that while RenderTexture assets can be only power-of-two size, it is possible to create a non-power-of-two render textures from scripts. These are most often used for image post processing effects.

Keep in mind that render texture contents can become "lost" on certain events, like loading a new level, system going to a screensaver mode, in and our of fullscreen and so on. When that happens, your existing render textures will become "not yet created" again, you can check for that with IsCreated function.

RenderTexture class is only available in Unity Pro.

Static Variables

activeThe active render texture.

Variables

antiAliasingThe antialiasing level for the RenderTexture.
colorBufferColor buffer of the render texture (Read Only).
depthThe precision of the render texture's depth buffer in bits (0, 16, 24 are supported).
depthBufferDepth buffer of the render texture (Read Only).
enableRandomWriteEnable DX11 random access write into this render texture.
formatThe format of the render texture.
generateMipsShould mipmap levels be generated automatically?
heightThe height of the render texture in pixels.
isCubemapIf enabled, this Render Texture will be used as a Cubemap.
isVolumeIf enabled, this Render Texture will be used as a Texture3D.
sRGBDoes this render texture use sRGB read / write (Read Only).
useMipMapUse mipmaps on a render texture?
volumeDepthVolume extent of a 3D render texture.
widthThe width of the render texture in pixels.

Constructors

RenderTextureCreates a new RenderTexture object.

Functions

CreateActually creates the RenderTexture.
DiscardContentsDiscards the contents of the RenderTexture.
IsCreatedIs the render texture actually created?
MarkRestoreExpectedIndicate that there's a RenderTexture restore operation expected.
ReleaseReleases the RenderTexture.
SetGlobalShaderPropertyAssigns this RenderTexture as a global shader property named propertyName.

Static Functions

GetTemporaryAllocate a temporary render texture.
ReleaseTemporaryRelease a temporary texture allocated with GetTemporary.
SupportsStencilDoes the RenderTexture have stencil buffer?

Inherited members

Variables

hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.
anisoLevelAnisotropic filtering level of the texture.
filterModeFiltering mode of the texture.
heightHeight of the texture in pixels. (Read Only)
mipMapBiasMip map bias of the texture.
widthWidth of the texture in pixels. (Read Only)
wrapModeWrap mode (Repeat or Clamp) of the texture.

Functions

GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.
GetNativeTextureIDRetrieve native ('hardware') handle to a texture.
GetNativeTexturePtrRetrieve native ('hardware') pointer to a texture.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.
SetGlobalAnisotropicFilteringLimitsSets Anisotropic limits.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares if two objects refer to the same.