I found tons of old tutorials that achieved a scrolling/parallaxy background effect by making a single sprite background to cover the screen, then every frame doing something like this:
Whenever I try to do the same, I get an error on my sprite renderer, “Material texture property _MainTex has offset/scale set. It is incompatible with SpriteRenderer”. The only disparity I can find between my implementation and everyone else’s is that older tutorials change their scrolling sprite’s Texture Type from Sprite to Texture. I don’t have a Texture option on my dropdown, and as far as I can tell that particular option was revised out of Unity quite a while ago.
So is there an alternative implementation I’m missing? Messing with the offsets like this seems so useful, I can’t imagine it was made completely impossible by the change.
I haven’t used offset with SpriteRenderer, since sprite slicing being added in Unity 4 took away the only reason I ever had to apply an offset to a sprite texture. It’s too bad that that doesn’t work…
Hmm, it looks like Default is intended to be used as a shader/material on 3d meshes- that’s the only context in which I can get it to apply, it looks like Default textures can’t be set as sprites in a 2d sprite renderer.
Sorry, I meant to not use a sprite renderer at all. As the fault describes, setting offset at the texture is apparently not compatible with SpriteRenderer. You can still use a textured quad (for instance) if you still want to use offset, perhaps as part of a UI canvas for scaling purposes.
Digging up this thread as it was a top search result when I was attempting to scroll a SpiteRenderer’s material without success.
I believe the best approach is to copy the default Sprite shader and modify it with your own scrolling texcoord offsets, which is what I’ve done below. I wish there was a proper way to “extend” or inherit from shaders, but the only way I know how to do this is copy the code and modify what you need. Fortunately, this is relatively straightforward.
Not sure I fully understand your question, but I believe so. I was able to dynamically adjust the size of the pattern. The texture I used was of course four way symmetrical.
This solution worked for me, but now I’m struggling with zSorting. I know you can use renderer.sortingLayerID with sprite textures – is there a way to do that with the default texture?