- Home /
Controlling the offset of a texture
Hey guys, i got this script from the manual:
 function Update () {
     var offset : float = Time.time * scrollSpeed;
     renderer.material.SetTextureOffset ("_MainTex", Vector2(offset,0));
 }
The way it is now the texture will keep offseting and needs 2 repeat(wrap mode), what i wanna do is to make the offset of the texture when reach say 1 returns to -3 and keep looping that way so i can clamp the texture. Any help will be appreciated since i'm new 2 programming
Answer by syclamoth · Mar 13, 2012 at 10:07 AM
private var currentOffset : float = -3; var resetTo : float = -3; var maxOffset : float = 1;
 
               function Update() { currentOffset += Time.deltaTime * scrollSpeed; if(currentOffset > maxOffset) { currentOffset = resetTo; } } 
Sorry, I just succumbed to one of the greatest evils of the UnityScript language. The first three lines should be changed to
 private var currentOffset : float = -3;
 var resetTo : float = -3;
 var maxOffset : float = 1;
Yep that was it. Sorry 4 wasting your time once more and thank you 4 your help.
Your answer
 
 
             Follow this Question
Related Questions
Material/Texture on the Inside of a Sphere 5 Answers
How can I swap an object's texture when I click? 2 Answers
CRT/LCD screen shader (for materials) 4 Answers
Material not shown on imported FBX sphere 0 Answers
change child texture problem 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                