Scrolling Textures on Mesh or Shader

Im not good in english.
Hi. I have a problem. I want make scrolling texture but scripts what I found scrolls only one material on mesh. My mesh have 4 materials and i need scroll only the one that I want.

This is the script:

using UnityEngine;
using System.Collections;

public class Scrolling: MonoBehaviour {
    public float scrollSpeed = 0.5F;
    public Renderer rend;
    void Start()
    {
        rend = GetComponent<Renderer>();
    }
    void Update()
    {
        float offset = Time.time * scrollSpeed;
        rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
    }
}

You can access them via the material__s__ array. Unity - Scripting API: Renderer.materials

Sure…

int matId = 1; // the array index for your material
float offset = Time.time * scrollSpeed;
rend.materials[matId].SetTextureOffset("_MainTex", new Vector2(offset, 0f));

Edit: Oh, you’ve deleted your post asking for an example?! Here it is anyway :slight_smile:

I thought of it myself but thx anyway)