- Home /
Mesh renderer - more than one material in submeshes
I'm using 3d Quad object to make infinite, scrolling, parallax background in my 2D unity game. I have a 4 submeshes in my mesh renderer. There are 3 materials (I have added an animation to it) in submesh number two.
To make parallax effect I'm using materials[i].mainTextureOffset
Everything works perfectly with only one material in submesh, but it doesn't work with animation.
Offset is changing when player is moving:
offset[i] = new Vector2(playerPosition.x / (1000 / parallaxspeed[i]), rendererTextures.materials[i].mainTextureOffset.y);
rendererTextures.materials[i].mainTextureOffset = offset[i];
Your answer
![](https://koobas.hobune.stream/wayback/20220612193216im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to check whether a lot of components and their children have a mesh renderer on them in code? 1 Answer
Renderer.material assignment not working 1 Answer
How to change a specific material of an object ? 0 Answers
How do I change the material of a prefab when it is not in the hierarchy? 0 Answers
Setting material based on vertex? 0 Answers