Skip to content

Format

typescript
RenderTexture.GetTemporary(width, height, colorFmt, depth, aa)

class: RenderTexture

Description

Allocate a temporary render texture.

This method is typically used when there is a need for intermediate rendering steps in the rendering pipeline, in order to avoid frequent creation and destruction of RenderTexture objects, thus improving performance and memory utilization efficiency.

Parameters

param_nametypedescription
widthnumberThe width of the texture.
heightnumberThe height of the texture.
colorFmtRenderTextureFormatThe format of the render texture.
depthDepthTypeThe depth texture.
aaAntiAliasingLevel?The anti-aliasing level.

Return

typedescription
RenderTexture|nullThe render texture.

Code Example

typescript
function Test() {
    try {
        let temp_texture = RenderTexture.GetTemporary(100, 100, RenderTextureFormat.Default, DepthType.Depth24Stencil8, AntiAliasingLevel.x8);
    } catch (error) {
        Debug.Log(error);
    }
}