# active

> Currently active graphics texture.

## Definition

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

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

### Remarks

All rendering goes into the active GraphicsTexture. If the active GraphicsTexture is null, everything renders in the main window. If the active render target is a [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), `GraphicsTexture.active` returns the [graphicsTexture](/engine/6000.0/script-reference/unityengine/texture/graphicstexture.md) of [RenderTexture.active](/engine/6000.0/script-reference/unityengine/rendertexture/active.md).

In order to set the active render target to a GraphicsTexture, it must have [GraphicsTextureDescriptorFlags.RenderTarget](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptorflags/rendertarget.md) enabled in [GraphicsTextureDescriptor.flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md) on texture creation.

Setting `GraphicsTexture.active` is the same as calling [Graphics.SetRenderTarget](/engine/6000.0/script-reference/unityengine/graphics/setrendertarget.md) with a single GraphicsTexture. Typically you change or query the active render target 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) with a [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md) instead.

Additional Resources: [GraphicsTextureDescriptorFlags.RenderTarget](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptorflags/rendertarget.md), [Graphics.SetRenderTarget](/engine/6000.0/script-reference/unityengine/graphics/setrendertarget.md), [RenderTexture.active](/engine/6000.0/script-reference/unityengine/rendertexture/active.md).

### Examples

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

// Get the contents of a GraphicsTexture into a Texture2D
public class ExampleClass : MonoBehaviour
{
    static public Texture2D GetGfxTexPixels(GraphicsTexture gfxTex)
    {
        // Remember currently active render target
        GraphicsTexture currentActiveRT = GraphicsTexture.active;

        // Set the supplied GraphicsTexture as the active one
        GraphicsTexture.active = gfxTex;

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

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