- Home /
texture offset and timing (slideshow effect)
Hi,
I'm trying to make a script to offset textures. I don't really need it to move, I need more of a slideshow effect, kind of where it just "pops" to the next frame.
I thought of laying out the pictures all next to each other and then just using a script such as the one described here to offset the texture.
How can I get it to wait a second or something, and then just move it to the next frame?
Here's what I'm trying:
var scrollspeed : float;
function Update () {
yield WaitForSeconds (2);
renderer.material.SetTextureOffset("_MainTex", Vector2(.5, 0));
}
Thanks in advance.
Answer by spinaljack · Oct 31, 2010 at 01:01 PM
You can't yield the update function, it has to run every frame.
Make a new function called slideShow with the yield or use a time stamp on the update function or invoke repeating
e.g.
function Start(){ StartSlideShow(2); }
function StartSlideShow(time : float){ While(true){ // infinite loop // move texture renderer.material.SetTextureOffset("_MainTex", Vector2(.5, 0)); yield WaitForSeconds(time); } }
You can break out of a while loop with a boolean flag if you wanted to pause/stop the slide show at any point.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081436im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
mainTextureOffset not updating via script 1 Answer
Scrolling Texture scrolls both maps. Only want single map to scroll? 0 Answers
Texture offset problem 0 Answers
Texture Offset Beyond 1 2 Answers
Offset texture based on world space 1 Answer