Offset texture based on world space
I'm looking for a way to make an object's texture offset when I move it in the scene. Let's say I have a cube, a 1024x1024 texture atlas divided in 4 equal parts with 4 different colors (red, green, blue, and yellow; just as an example), and the cube's UV will cover one of those 4 sides, so it will show one of the four colors. How do I make the texture continuously offset while I move the cube in my scene, so that everytime I move it, it will show one of the colors on the texture atlas? And if I keep moving it, it will keep scrolling through the four colors, over and over again.
I was thinking of having the texture offset half way in a direction so it will show one of the other colors, but I don't know how to make that happen while the cube's position changes in my scene. Can someone point me in the right direction?
Thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612133725im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to import dds file to Unity? 0 Answers
Solid color texture or adding a color property to shader? 1 Answer
How can I apply a 9-slice scaling to a mash object using a shader? 0 Answers
HIde 3D objects behind segmented pixels of 2D texture 1 Answer
How do you draw a sprite from an atlas on to a mesh? 1 Answer