For Starters, I am an Artist above all else, I am just learning the JavaScript side of Unity. I have a line renderer attached (as a component) to a cube and I am trying to offset the UV coordinates via the following code. The script is attached to the Unity Cube: Code (csharp): // Scroll main texture based on time var scrollSpeed = 0.1; function Update () { var offset = Time.time * scrollSpeed; GetComponent(LineRenderer).material.SetTextureOffset ("_MainText", Vector2(offset/10.0, offset)); } Currently; I do not have any compile-time errors and no run-time errors either, but nothing happens. My end result should be a scrolling line renderer material with a non scrolling cube material. P.S. This script has been modified from the Unity Sewer-demo Scene. I appreciate all help/tips in advance. ~cDixRun
The property name for the main texture is usually _MainTex, not _MainText. If there isn't a property called _MainText, that would explain why your code compiles but still doesn't work.
ah, crap... in all of my editing of the script, I must have messed that up. Thanks Andee, that did it.
Texture offset is not the same thing as UV offset, which normally you need a reference to a Mesh instance to be able to alter. The difference may seem slight, but it's rather significant. I've heard that when you dynamically alter the texture offset of a material that is being used by more than one object, a copy of that material is made, which increases the number of materials used in the scene, thus the draw calls, and thus reduces performance. Editing the UVs of a mesh instance, however, does not copy the material, and is the better way to go if you're seeking optimization. So, is there a way do truly edit the UVs through a Mesh instance with LineRenderer?