I’m trying to making my texture animate by scrolling it rapidly from side to side… I’ve found several answers here, all pointing to “Material.mainTextureOffset”, which then brings up a page that shows multiple lines of scripting…
I’m VERY new to Unity, and I’m not sure how I’m supposed to use this code… Do I cut and paste it into a certain shader? If it’s the Diffuse shader, Unity doesn’t seem to let me access the script…
Please, I’d be very appreciative if someone would explain to me exactly how I use Material.mainTextureOffset to make my textures scroll…
Inside unity’s code, when the object is drawn, the material will give that offset to the shader. You don’t need to change the shader what so ever in that case.
What you need to do though, is a a reference to that material, probably in a class inheriting from MonoBehaviour (if your using javascript, it means a regular script). Then affect a new value to the property material.mainTextureOffset. Now, you want this to be animated, so you’ll need to give a new value to mainTextureOffset each times you want the result to change.
If you need more details, I’ll can explain further.