Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

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

RenderTexture

Namespace: UnityEngine

/

Inherits from: Texture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

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

active The active render texture.

Variables

antiAliasing The antialiasing level for the RenderTexture.
colorBuffer Color buffer of the render texture (Read Only).
depth The precision of the render texture's depth buffer in bits (0, 16, 24 are supported).
depthBuffer Depth buffer of the render texture (Read Only).
enableRandomWrite Enable DX11 random access write into this render texture.
format The format of the render texture.
generateMips Should mipmap levels be generated automatically?
height The height of the render texture in pixels.
isCubemap If enabled, this Render Texture will be used as a Cubemap.
isVolume If enabled, this Render Texture will be used as a Texture3D.
sRGB Does this render texture use sRGB read / write (Read Only).
useMipMap Use mipmaps on a render texture?
volumeDepth Volume extent of a 3D render texture.
width The width of the render texture in pixels.

Constructors

RenderTexture Creates a new RenderTexture object.

Functions

Create Actually creates the RenderTexture.
DiscardContents Discards the contents of the RenderTexture.
IsCreated Is the render texture actually created?
MarkRestoreExpected Indicate that there's a RenderTexture restore operation expected.
Release Releases the RenderTexture.
SetGlobalShaderProperty Assigns this RenderTexture as a global shader property named propertyName.

Static Functions

GetTemporary Allocate a temporary render texture.
ReleaseTemporary Release a temporary texture allocated with GetTemporary.
SupportsStencil Does the RenderTexture have stencil buffer?

Inherited members

Variables

hideFlags Should the object be hidden, saved with the scene or modifiable by the user?
name The name of the object.
anisoLevel Anisotropic filtering level of the texture.
filterMode Filtering mode of the texture.
height Height of the texture in pixels. (Read Only)
mipMapBias Mip map bias of the texture.
width Width of the texture in pixels. (Read Only)
wrapMode Wrap mode (Repeat or Clamp) of the texture.

Functions

GetInstanceID Returns the instance id of the object.
ToString Returns the name of the game object.
GetNativeTextureID Retrieve native ('hardware') handle to a texture.
GetNativeTexturePtr Retrieve native ('hardware') pointer to a texture.

Static Functions

Destroy Removes a gameobject, component or asset.
DestroyImmediate Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoad Makes the object target not be destroyed automatically when loading a new scene.
FindObjectOfType Returns the first active loaded object of Type type.
FindObjectsOfType Returns a list of all active loaded objects of Type type.
Instantiate Clones the object original and returns the clone.
SetGlobalAnisotropicFilteringLimits Sets Anisotropic limits.

Operators

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