Good afternoon, I made an animation for one of my UI images that work as icons.
It works but I have three problems:
- How can I use the same animation for the rest of the UI Images? I cannot see any “upload anim”.
- I have a script with a switch; each case represents a button clicked in my menu.
So I want to run an animation when “X” button is pressed, another when “Y” button is pressed.
How can I do? Is it possible to load an array of animators? - Is there a function like Animator.Play()?
The problem is I have never animate any object and I sincerely don’t have a clue on how to do it.
Anyway, here’s my code:
public Animator [] Icons;
public int AnimToPlay = -1; //It goes from 0 to 5 and indicates what animation has to be played when a certain button is triggered
public void Start()
{
MyMusic = GetComponent<AudioSource> (); //Get the Audio Reference
}
public void ButtonClicked(RectTransform Clicked) //This recognizes which button I cliccked
{
Debug.Log ("The button clicked was " + Clicked.name);
switch (Clicked.name)
{
case "btn_enroll":
AnimToPlay = 0;
PlayAnimations (AnimToPlay);
;
break;
and PlayAnimations method:
void PlayAnimations(int Play)
{
Icons [Play].Play(); //Here it says me it needs an argument; what string?
}