How to set up a scrub bar in Unity??

Hi,

I’ve got a project coming up that will require the users to be able to scrub the playback of a (fix) animation of a large scale event. The play back options will require to have a scrub bar at the bottom of the screen with a play pause option. The idea is while playing back the animation they can choose new camera locations to view the project at different times in the event.

I will be honest I lack the skills to set this up, any one have any ideas or hints on how I can set this up?

Many thanks,

Shaun.

I am a bit new to Unity as well, however here is how I would approach it.
First off, definitely going to need an OnGUI() script to add the bar, and the button to swap camera angles.
Something along the lines of…

var reso=0;
var hSliderValue : float = 0.0;
var lastValue:float=0.0;

function Start() {
  reso=Screen.currentResolution;
}

function OnGUI () {
    GUI.Box (Rect (5,30,reso.x-5,reso.y-35),"");

    if (GUI.Button (Rect (10,reso.y-(25),150,25), "Change Angle")) {
           // in here you can translate camera to new position
   }
   lastValue = GUI.HorizontalSlider (Rect ((10)+(150)+5, reso.y-(25), reso.x-(150)-10, 15), hSliderValue, 0.0, 100.0);
}
function Update() {
  var delta_amt:float=0.0;
   
   if (lastValue==hSliderValue) { // user has not altered slider percentage completion
      var speedStep:float=0.05;
      delta_amt=(hSliderValue/100)+speedStep;  // calculate "normal" delta change here for playback speed. Just an example here using percentage -- 0.0 to 1.0 --  
       // perhaps use the animated model's anim speed for current action, added to/subtracted from delta_amt, so that you can "sequence" multiple animation actions... 
      ...
      
   } else { // otherwise user updated it manually before the animation was performed, thus: We need to alter the current delta
         var diff=hSliderValue-lastValue;
         if (diff>=0) { // moved to future point
              // jump the animation to future sequence state/cam pos.
         } else { // moved to past point
               // jump the animation to past sequence state/cam pos.
         }
       delta_amt=(hSliderValue/100)+diff;
   }

     //  Move camera along an axis here at delta val rate.. etc.
    hSliderValue=tempPercentage+(delta_amt*100);  // dont forget to update slider position on gui
}

So yea, the above is pretty sketchy, probably isn’t fully logically sound either.but that’s where I would start.

Also see:

and http://answers.unity3d.com/questions/51108/scrolling-through-animation-with-sliders.html

Someone more knowledgeable probably has better options info for you, good luck

Thanks for the reply.

I’ve exported an animation from LW (About 3000 frames at (25fps), now what I want to do is use the slider to scrub through the animation.
The slider will be a % bar 0 - 100% Say I set the slider to 50%, I then need to set the animation to frame 1500. If the play button is clicked the animation will then resume from there.
So now the big question is how do I set the animation to follow this?
I can’t find any reference to play animations from a set frame.