- Home /
Line Renderer repeating tiled texture every other tile is flipped
I created an animated material with this script public int columns; public int rows; public float framesPerSecond = 10f; public LineRenderer linerenderer;
//the current frame to display
private int index = 0;
void Start()
{
StartCoroutine(updateTiling());
//set the tile size of the texture (in UV units), based on the rows and columns
Vector2 size = new Vector2(1f / columns, 1f / rows);
linerenderer.sharedMaterial.SetTextureScale("_MainTex", size);
}
private IEnumerator updateTiling()
{
while (true)
{
//move to the next index
index++;
if (index >= rows * columns)
index = 0;
//split into x and y indexes
Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
(index / columns) / (float)rows); //y index
linerenderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
yield return new WaitForSeconds(1f / framesPerSecond);
}
}
I have the sprites wrapping mode set to repeat, and the line renderer is set to tiled. The result is almost what I want, but every other tile is flipped, ruining the animation. The material's shader is set to particles additive, and i'm doing this in 2D
Answer by JiveViking · Aug 22, 2020 at 03:53 PM
Bumping this, does anyone know if this is just an issue with linerenderer or what setting might need to be changed?
Your answer
![](https://koobas.hobune.stream/wayback/20220613010229im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shader Edit Help: 2D Outline Coloring 2 Answers
Sprite obstruction transparent area 1 Answer
Black boarder on transparent sprites 2 Answers
Best Practices on 2D Animation? 1 Answer