The animation consists of a balloon inflating as the slider is moved towards the right. Can someone explain as to how this could be achieved in C# script?
I’m assuming you want the slider to control the animation, and that you are using a uGUI slider and an Animator. If that’s the case, you might be able to use something like this:
public Slider slider;
public Animator animator;
void Start()
{
slider.onValueChanged.AddListener(OnValueChanged);
}
private void OnValueChanged()
{
animator.speed = 0;
animator.Play("yourAnimationName", -1, slider.normalizedValue);
}
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;
}
}