# active

> Currently active render texture.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static RenderTexture active { get; set; }
```

### Remarks

All rendering goes into the active RenderTexture. If the active RenderTexture is null everything is rendered in the main window.

Setting [RenderTexture.active](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) is the same as calling [Graphics.SetRenderTarget](/engine/6000.0/script-reference/unityengine/graphics/setrendertarget.md). Typically you change or query the active render texture when implementing custom graphics effects; if all you need is to make a Camera render into a texture then use [Camera.targetTexture](/engine/6000.0/script-reference/unityengine/camera/targettexture.md) instead.

When a RenderTexture becomes active its hardware rendering context is automatically created if it hasn't been created already.

Additional Resources: [Graphics.SetRenderTarget](/engine/6000.0/script-reference/unityengine/graphics/setrendertarget.md), [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md).

### Examples

```csharp
using UnityEngine;
using System.Collections;

// Get the contents of a RenderTexture into a Texture2D
public class ExampleClass : MonoBehaviour
{
    static public Texture2D GetRTPixels(RenderTexture rt)
    {
        // Remember currently active render texture
        RenderTexture currentActiveRT = RenderTexture.active;

        // Set the supplied RenderTexture as the active one
        RenderTexture.active = rt;

        // Create a new Texture2D and read the RenderTexture image into it
        Texture2D tex = new Texture2D(rt.width, rt.height);
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
        tex.Apply();

        // Restore previously active render texture
        RenderTexture.active = currentActiveRT;
        return tex;
    }
}
```
