Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Material.SetTextureOffset

Switch to Manual
public function SetTextureOffset(propertyName: string, offset: Vector2): void;

Parameters

Description

Sets the placement offset of texture propertyName.

Common texture names used by Unity's builtin shaders:
"_MainTex" is the main diffuse texture. This can also be accessed via mainTextureOffset property.
"_BumpMap" is the normal map.
"_Cube" is the reflection cubemap.

See Also: mainTextureOffset property, GetTextureOffset.

// Scroll main texture based on time

var scrollSpeed : float = 0.5; var rend: Renderer;

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

function Update () { var offset : float = Time.time * scrollSpeed; rend.material.SetTextureOffset("_MainTex", Vector2(offset,0)); }