# SetTextureOffset

> Sets the placement offset of a given texture. The name parameter is defined in the shader. This method creates a new Material instance.

## Definition

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

## SetTextureOffset(string, Vector2)

Sets the placement offset of a given texture. The name parameter is defined in the shader. This method creates a new Material instance.

```csharp
public void SetTextureOffset(string name, Vector2 value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the texture property as defined in the shader. For example: "\_MainTex".**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): Texture placement offset.

### Remarks

Additional Resources: [Material.mainTextureOffset](/engine/6000.0/script-reference/unityengine/material/maintextureoffset.md) property, [Material.GetTextureOffset](/engine/6000.0/script-reference/unityengine/material/gettextureoffset.md), [Material.SetTexture](/engine/6000.0/script-reference/unityengine/material/settexture.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Scroll main texture based on time

    float scrollSpeed = 0.5f;
    Renderer rend;

    void Start()
    {
        rend = GetComponent<Renderer> ();
    }

    void Update()
    {
        float offset = Time.time * scrollSpeed;
        rend.material.SetTextureOffset("_TextureName", new Vector2(offset, 0));
    }
}
```

## SetTextureOffset(int, Vector2)

Sets the placement offset of a given texture. The name parameter is defined in the shader. This method creates a new Material instance.

```csharp
public void SetTextureOffset(int nameID, Vector2 value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Property name ID, use [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md) to get it.**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): Texture placement offset.

### Remarks

Additional Resources: [Material.mainTextureOffset](/engine/6000.0/script-reference/unityengine/material/maintextureoffset.md) property, [Material.GetTextureOffset](/engine/6000.0/script-reference/unityengine/material/gettextureoffset.md), [Material.SetTexture](/engine/6000.0/script-reference/unityengine/material/settexture.md).

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    // Scroll main texture based on time

    float scrollSpeed = 0.5f;
    Renderer rend;

    void Start()
    {
        rend = GetComponent<Renderer> ();
    }

    void Update()
    {
        float offset = Time.time * scrollSpeed;
        rend.material.SetTextureOffset("_TextureName", new Vector2(offset, 0));
    }
}
```
