Translate or Rotate a texture of a cube

Hello, I’ve seen an example and tried to apply it to a cube where I selected a texture/shader.

This doesn’t seem to do anything to my cube, and I would like to see the texture translate or rotate on my cube.

var rotateSpeed = 30;
var texture : Texture;

function Start () {
        var m : Material = new Material (
            "Shader \"Rotating Texture\" {" +
            "Properties { _MainTex (\"Base\", 2D) = \"white\" {} }" +
            "SubShader {" +
            "    Pass {" +
            "        Material { Diffuse (1,1,1,0) Ambient (1,1,1,0) }" +
            "        Lighting On" +
            "        SetTexture [_MainTex] {" +
            "            matrix [_Rotation]" +
            "            combine texture * primary double, texture" +
            "        }" +
            "    }" +
            "}" +
            "}"
        );
        m.mainTexture = texture;
        this.renderer.material = m;
}

function Update () {
	// Construct a rotation matrix and set it for the shader
        var rot = Quaternion.Euler (0, 0, Time.time * rotateSpeed);
        var m = Matrix4x4.TRS (Vector3.zero, rot, Vector3(1,1,1) );
        this.renderer.material.SetMatrix ("_Rotation", m);
}

Thank you

Well I’ve done a simple script to make a texture move, the settings are public in the inspector. This is in C#, but should be easy for you to figure out how to put in JS. If you can’t figure out how just let me know and I’ll help. I use this for things like water, lava, whatever… This allows movement of texture and normal map, just use the checkboxes in the inspector.

public class TexOffset : MonoBehaviour 
{
	public float scrollSpeedX = 0.1f;
	public float scrollSpeedY = 0.1f;
	public bool main = true;
	public bool bump = true;
	
	void Update () 
	{
		float offsetX = scrollSpeedX * Time.time;
		float offsetY = scrollSpeedY * Time.time;
		if(main)
		{
			renderer.material.SetTextureOffset("_MainTex", new Vector2(offsetX, offsetY));
		}
		if(bump)
		{
			renderer.material.SetTextureOffset("_BumpMap", new Vector2(offsetX, offsetY));
		}
	}
}

Thankyou very much, here is the code I used.

public var scrollSpeedX:float = 0.0;
public var scrollSpeedY:float = 0.1;

public var main = true;
public var bump = true;

function Update() {
	var offsetX:float = scrollSpeedX * Time.time;
	var offsetY:float = scrollSpeedY * Time.time;
	if(main) {
		this.renderer.material.SetTextureOffset("_MainTex", new Vector2(offsetX,offsetY));
	}
	if(bump) {
		this.renderer.material.SetTextureOffset("_BumpMap", new Vector2(offsetX,offsetY));
	}
}

Unfortunatly the material doesnt seem to support BumpMap, so it gives an error on that property. But beside that, it works like a charm.

The only problem now, is that while the “skybox” scrolls, I can see the divisions between them, is there a way to solve that?