title: Unity 5 mecanim animation controlled by UI slider
body: <p>I'm trying to get a slider to control an animation in my scene. I need to the length of the slider to match the length of the animation and when I scrub the slider, the animation should play the appropriate part. </p>
  
  <pre><code> public Slider slider;
  public Animator animator;
  
  void Start()
  {
      slider.onValueChanged.AddListener(OnValueChanged);
  }
  
  private void OnValueChanged(float changedValue)
  {
      animator.speed = 0;
      animator.Play("yourAnimationName", -1, slider.normalizedValue);
  }
  </code></pre>
  
  <p>I have also placed this on my slider components on value changed section but the two still do not synch up. What is it I'm doing wrong / missing?</p>
  
  <p><em>edit</em>
  updated code sample and removed the error</p>