How to scroll a region of texture (which is an atlas) on a mesh (which is a sprite)

Hi! I can’t find any answer for this particularly problem. All answers ignore the fact that texture can be used as an atlas. So here we go:

I have an atlas of sprites imported as a texture in a wrapped mode. Now basing on meta info of that atlas I generated prefabs with meshes (2 polygons for each mesh of a sprite with proper dimension + transparent shader - it does the job well) with properly set texture on them (done through TexturePackerImporter).

Now the question is how to scroll that texture, so I can get the moving background (hills) or foreground (grass). Right now when doing SetTextureOffset on a material the whole texture is moving - so on that mesh I can see other paintings from atlas.

What I want achieve is to have wrapping around particular clipped region of a texture.

Ok, I have an idea. I won’t scroll texture. I will just create two more meshes (or more if needed) beside original one and move all of them. Of course after reaching some position, they will be spawned “at the begin”. This way I will create infinity looking plane. Moreover I can zoom out/zoom in them.

I think it’s impossible using what you are trying now. Think you’d need to put the code in a custom shader. My logic:

A scrolling texture works based on the way Wrapping works. The graphics card thinks the right side of the entire texture is touching the left, and that past the right really, really is starting on the left. Now, say an atlas has your texture from x=0.2 to x=0.3 (out of 0 to 1.) The sprite UV coords, which would normally be 0-1, are now hand-crafted to map 0.2 to 0.3 over the sprite. So far, so good.

Now, you can shift those to: 0.21 to 0.31. That will shift the image 10%. But, Wrapping doesn’t understand that 0.31 is 0.01 past your right side, or that it should wrap the extra 0.01 starting from your left side of 0.2. There’s no switch or setting to alter wrapping rules. It would take a custom shader, with these numbers sent, to do the math.