How do I programmatically change the offset of a texture?


I have a surface for a television screen, which has the texture of static applied. So, to make the static actually happen, I want to programmatically change the offset of the texture every couple of frames.

But, I don’t know what the property or method is called, or how I can access the texture and its offset. How do I write the code to accomplish changing the offset (from a parent object)?

It is Material.mainTextureOffset. Some sample code in the reference page:

I didn’t know… so I googled… like you should have “unity3d set texture offset”

Its a good point the answer, anyways in my case im looking at how to do this but using mesh.uv , i need to achieve the same result that with the main texture offset but using mesh.uv , anyone know this? coz so far i think this would improve draw calls , other ways , maintextureOffset change i think is not good coz that would still make an extra draw call using atlasing so i believe it dosnt have much sense. thanks

Material material = gameObject.GetComponent().material;
offset = 0.001f;
material.SetTextureOffset(“_MainTex”, new Vector2(0, offset));