- Home /
SetTextureOffset not visible
I'm trying to show an animation on the inside of a cylinder. I have a texture map with two images below each other and every 5 frames I set the texture y offset either to 0 or to 1053 (top/bottom image). In the inspector I can see the y offset change, but on screen nothing happens to the texture. The inside of the cylinder is UV mapped to the top half of the texture. Can I use SetTextureOffset to animate this?
I've modified the code to simply scroll using mainTextureOffset, and again in the inspector the y offset changes, but nothing happens in the game. I'm wondering if this can have anything to do with the fact that the texture is tiled on the inside of the cylinder? Or is there something I need to activate before the offset becomes visible?
tmpOffset.x = 0.0f;
tmpOffset.y = currAniFramenr++;
ren.material.EnableKeyword("_MainTex");
ren.material.mainTextureOffset = tmpOffset;
I know I have the correct renderer because I can see the original texture and below I see the offset.y value change during gameplay. The inside of the cylinder is UV mapped to the top half of the texture.
Answer by unitylepi · Nov 18, 2019 at 09:46 AM
If anyone runs into this, I found the answer through some debugging, the docs only say:
public void SetTextureOffset(int nameID, Vector2 value);
value Texture placement offset.
Which gave me the idea the offset would be in pixels (think I also read that somewhere), but it's not. It's a percentage of the texture size. So, where I wanted to jump to pix 1053, I should have been jumping to 0.5f
Your answer
![](https://koobas.hobune.stream/wayback/20220612214938im_/https://answers.unity.com/themes/thub/images/avi.jpg)