So I have problem, how I control animation with UI slider, so if I am moving slider forward it plays animation forward and if backwards it plays animation backwards. I have this script, but it doesn’t work anymore in U5 and I have no idea how to make it work with UI slider.
var sliderPos : float = 0;
var animationName = "metarig|height";
function Start() {
animation[animationName].enabled = true;
animation[animationName].weight = 1;
}
function OnGUI() {
sliderPos = GUI.HorizontalSlider(Rect(40,40,400,20), sliderPos, 0.0, 1.0);
animation[animationName].normalizedTime = sliderPos;
}
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class AnimControl : MonoBehaviour {
Animation anim;
public Slider slider;
// Use this for initialization
void Start () {
anim = GetComponent<Animation> ();
anim.Play ("SphereAnim");
anim ["SphereAnim"].speed = 0;
}
// Update is called once per frame
void Update () {
anim["SphereAnim"].time = slider.value;
}
}