Reverse Animtion On clicking text.

hello, This code Reverse animation for only once , if we click another time it does not working.

Script 1 for animation when click on 3Dtext[box collider]

var playing : boolean = false;
var gameobject : GameObject;

function OnMouseDown ()

{

   if (!playing) {
     playing = true;
     gameobject.animation["Credit"].speed = 1.0;
     yield WaitForSeconds(gameobject.animation["Credit"].length);
      playing = false;

   }

} 
script 2 for reversing  animation on clicking 3Dtext [Boxcollider]
   
var playing : boolean = false;
var gameobject : GameObject;

function OnMouseDown ()

{

   if (!playing) {
     playing = true;
     gameobject.animation["Credit"].speed = -1.0;
     yield WaitForSeconds(gameobject.animation["Credit"].length);
      playing = false;

   }

}

This thing is working good but here’s my problem if user click again on the script1 text animation i mean after clicking on Script2 which reverse animation when it comes back to original state clicking on script1 text doesn’t work …

thank you

As far as I understand you need to rewind it first to the end.

 playing = true;

 gameobject.animation["Credit"].time = gameobject.animation["Credit"].length; //

 gameobject.animation["Credit"].speed = -1.;
 yield WaitForSeconds(gameobject.animation["Credit"].length);

Hi, if you don’t absolutely need/want an animtion can try this for a gui

look at the second, the AdvancedMarquee.cs

with a bit more code I think can add button to switch direction of scroll

unifycommunity- AdvancedMarquee.cs