Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

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

RenderTexture

class in 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

Submission failed

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

Close

Cancel

Switch to Manual

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.

One typical usage of render textures is setting them as the "target texture" property of a Camera (Camera.targetTexture), this will make a camera render into a texture instead of rendering to the screen.

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 out 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.

As with other "native engine object" types, it is important to pay attention to the lifetime of any render textures and release them when you are finished using them with the Release function, as they will not be garbage collected like normal managed types.

See Also: Camera.targetTexture.

Static Properties

activeCurrently active render texture.

Properties

antiAliasingThe antialiasing level for the RenderTexture.
autoGenerateMipsMipmap levels are generated automatically when this flag is set.
bindTextureMSIf true and antiAliasing is greater than 1, the render texture will not be resolved by default. Use this if the render texture needs to be bound as a multisampled texture in a shader.
colorBufferColor buffer of the render texture (Read Only).
depthThe precision of the render texture's depth buffer in bits (0, 16, 24/32 are supported).
depthBufferDepth/stencil buffer of the render texture (Read Only).
descriptorThis struct contains all the information required to create a RenderTexture. It can be copied, cached, and reused to easily create RenderTextures that all share the same properties.
dimensionDimensionality (type) of the render texture.
enableRandomWriteEnable random access write into this render texture on Shader Model 5.0 level shaders.
formatThe color format of the render texture.
heightThe height of the render texture in pixels.
memorylessModeThe render texture memoryless mode property.
sRGBDoes this render texture use sRGB read/write conversions (Read Only).
useDynamicScaleIs the render texture marked to be scaled by the Dynamic Resolution system.
useMipMapRender texture has mipmaps when this flag is set.
volumeDepthVolume extent of a 3D render texture or number of slices of array texture.
vrUsageIf this RenderTexture is a VR eye texture used in stereoscopic rendering, this property decides what special rendering occurs, if any.
widthThe width of the render texture in pixels.

Constructors

RenderTextureCreates a new RenderTexture object.

Public Methods

CreateActually creates the RenderTexture.
DiscardContentsHint the GPU driver that the contents of the RenderTexture will not be used.
GenerateMipsGenerate mipmap levels of a render texture.
GetNativeDepthBufferPtrRetrieve a native (underlying graphics API) pointer to the depth buffer resource.
IsCreatedIs the render texture actually created?
MarkRestoreExpectedIndicate that there's a RenderTexture restore operation expected.
ReleaseReleases the RenderTexture.
ResolveAntiAliasedSurfaceForce an antialiased render texture to be resolved.
SetGlobalShaderPropertyAssigns this RenderTexture as a global shader property named propertyName.

Static Methods

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

Inherited Members

Properties

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.
dimensionDimensionality (type) of the texture (Read Only).
filterModeFiltering mode of the texture.
heightHeight of the texture in pixels. (Read Only)
imageContentsHashThe hash value of the Texture.
mipMapBiasMip map bias of the texture.
widthWidth of the texture in pixels. (Read Only)
wrapModeTexture coordinate wrapping mode.
wrapModeUTexture U coordinate wrapping mode.
wrapModeVTexture V coordinate wrapping mode.
wrapModeWTexture W coordinate wrapping mode for Texture3D.

Public Methods

GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the GameObject.
GetNativeTexturePtrRetrieve a native (underlying graphics API) pointer to the texture resource.

Static Methods

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 two object references to see if they refer to the same object.
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答