# DrawGUITexture

> Draw a texture in the Scene.

## Definition

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

## DrawGUITexture(Rect, Texture, int, int, int, int, Material)

Draw a texture in the Scene.

```csharp
public static void DrawGUITexture(Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The size and position of the texture on the "screen" defined by the XY plane.**** (\[Texture]\(/engine/6000.0/script-reference/unityengine/texture)): The texture to be displayed.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Inset from the rectangle's left edge.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Inset from the rectangle's right edge.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Inset from the rectangle's top edge.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Inset from the rectangle's bottom edge.**** (\[Material]\(/engine/6000.0/script-reference/unityengine/material)): An optional material to apply the texture.

### Remarks

The chosen texture is drawn in 3D space on a "screen" defined by the XY plane (ie, the plane where the Z coordinate is zero). The values of the texture rectangle are given in Scene units. The optional border values specify an inset from each edge within the rectangle in Scene units; the texture is drawn inside the inset rectangle and the edge pixels are repeated outwards. This is a useful quick way to create a large background region around the main texture when its edges are of a single colour.

This function can be useful for creating GUI backgrounds in conjunction with a camera pointing directly at the texture.

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public Texture myTexture;

    void OnDrawGizmosSelected()
    {
        // Draw a texture rectangle on the XY plane of the scene
        Gizmos.DrawGUITexture(new Rect(10, 10, 20, 20), myTexture);
    }
}
```

## DrawGUITexture(Rect, Texture, Material)

Draw a texture in the Scene.

```csharp
public static void DrawGUITexture(Rect screenRect, Texture texture, Material mat)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): The size and position of the texture on the "screen" defined by the XY plane.**** (\[Texture]\(/engine/6000.0/script-reference/unityengine/texture)): The texture to be displayed.**** (\[Material]\(/engine/6000.0/script-reference/unityengine/material)): An optional material to apply the texture.

### Remarks

The chosen texture is drawn in 3D space on a "screen" defined by the XY plane (ie, the plane where the Z coordinate is zero). The values of the texture rectangle are given in Scene units. The optional border values specify an inset from each edge within the rectangle in Scene units; the texture is drawn inside the inset rectangle and the edge pixels are repeated outwards. This is a useful quick way to create a large background region around the main texture when its edges are of a single colour.

This function can be useful for creating GUI backgrounds in conjunction with a camera pointing directly at the texture.

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public Texture myTexture;

    void OnDrawGizmosSelected()
    {
        // Draw a texture rectangle on the XY plane of the scene
        Gizmos.DrawGUITexture(new Rect(10, 10, 20, 20), myTexture);
    }
}
```
