using UnityEngine;
using System.Collections;

public class AnimationControlDemo : MonoBehaviour {
    
	public float animSpeed = 1f;
    private Animator animator;
    
    void Start () {
        animator = gameObject.GetComponent<Animator>();
    }

    void FixedUpdate() {
        animator.speed = animSpeed;
        if (!animator.enabled) animator.Update(Time.fixedDeltaTime);
    }

    void OnGUI() {
        int cLocation = Screen.width - 180;
        if (gameObject.name == "Constructor_Enabled"){
            cLocation = 30;
        }
        GUI.BeginGroup(new Rect(cLocation, 10, 200, 200)); {
            GUILayout.Label("Animator Enabled = " + animator.enabled);
            GUILayout.Label("Speed (" + animSpeed + ")");
            animSpeed = GUILayout.HorizontalSlider(animSpeed, 0, 5f);
        } GUI.EndGroup();
    }
}
