Search Unity

Animation.play not working on button

Discussion in 'Scripting' started by GreenBoxInteractive, Jul 18, 2015.

  1. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    I have an animation clip that moves buttons about, then I want it to play on a button press. I have this script at the moment, but nothing happens, no errors.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class toShopAnim : MonoBehaviour {
    5.    
    6.     public Animation anim;
    7.  
    8.     void Start(){
    9.         anim = GetComponent<Animation>();
    10.         }
    11.  
    12.     public void shopButton(){
    13.         anim.Play ("toShop", PlayMode.StopAll);
    14.     }
    15. }
    16.