- Home /
Repeatable 2D Texture on Linerenderer
I try to create a Linerenderer (Positions update every Frame) which uses a texture that is repeated depending on the needed length.
Therefore I tried the following:
1) Creating a reapeatable texture
2) Creating a Material (Sprite/Default Shader) which uses this texture.
3) Changing the texture's scale when needed:
//Update Linderenderer
linerenderer.SetPosition(0, transform.position);
linerenderer.material.SetTextureScale("_MainTex", new Vector2(hook_joint.distance,1));
Debug.Log(linerenderer.material.GetTextureScale("_MainTex"));
The Debug Log shows that the texture scale changes over time, the change is however not visible? Do i change the wrong texture on the material or is this kind of approach totaly wrong?
I allready found several answers to this question , which range from using special shaders to chaining linerenderers together (multiple linerenderers with fixed length) . Most of these answers however do not cover the use of a transparent key in the texture (my chain has holes ) or do only work in 3D.
Answer by TheCheatsrichter · Jun 02, 2016 at 11:05 AM
The shader Sprites/Default does not use any of he Texture Scale functions! I changed the material shader to standart and used the Cutout rendering mode to achieve the transparancy in the chain. After that the code from above works perfectly and the line renderer displays in the correct scale at each frame.
Answer by anil4029 · Jan 07, 2017 at 08:27 PM
change material shader to standard and then click on emission and choose same texture.