I m applying animation to the UI elements. Here i have used the Trigger parameters the parameters
are “Rem” and “Rev”
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
public bool isPause = false;
public static UIManager Instance;
public Text enaryText;
public int enargyLossValue = 2;
// Use this for initialization
void Awake ()
{
Instance = this;
//UIManager.Instance.enaryText.text = ""+PlayerPrefs.GetInt("highScore");
}
public GameObject resumeMenu;
public GameObject gamePlayUI;
private Animator anim;
void Start ()
{
anim = resumeMenu.GetComponent<Animator> ();
anim = gamePlayUI.GetComponent<Animator> ();
resumeMenu.SetActive (false);
gamePlayUI.SetActive (true);
anim.SetBool ("IsGP", false);
isPause = false;
}
public void Pause ()
{
isPause = true;
resumeMenu.SetActive (true);
anim.SetBool ("IsGP", true);
anim.SetTrigger("Rev"); //here its working fine
}
public void Reuse ()
{
StartCoroutine (Resume ());
}
IEnumerator Resume ()
{
isPause = false;
anim.SetTrigger("Rem"); //here its not playing the animation
anim.SetBool ("IsGP", false);
yield return new WaitForSeconds (3f);
resumeMenu.SetActive (false);
}
}
i have resolved this problem, by using two different animator variables
and this time i have used bool parameters, this is working fine. Thank U
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
public bool isPause = false;
public static UIManager Instance;
public Text enaryText;
public int enargyLossValue = 2;
// Use this for initialization
void Awake ()
{
Instance = this;
//UIManager.Instance.enaryText.text = ""+PlayerPrefs.GetInt("highScore");
}
public GameObject resumeMenu;
public GameObject gamePlayUI;
private Animator anim, anim1; // here i have used two variables
void Start ()
{
// use different animator for different game object see above start
anim1 = resumeMenu.GetComponent<Animator> ();
anim = gamePlayUI.GetComponent<Animator> ();
resumeMenu.SetActive (false);
gamePlayUI.SetActive (true);
anim.SetBool ("IsGP", false);
anim1.SetBool ("Rem", false);
anim1.SetBool ("Rev", false);
// Time.timeScale = 1;
isPause = false;
}
public void Pause ()
{
isPause = true;
resumeMenu.SetActive (true);
anim.SetBool ("IsGP", true);
anim1.SetBool ("Rem", true);
anim1.SetBool ("Rev", false);
}
public void Reuse ()
{
StartCoroutine (Resume ());
}
IEnumerator Resume ()
{
anim1.SetBool ("Rem", false);
anim1.SetBool ("Rev", true);
anim.SetBool ("IsGP", false);
yield return new WaitForSeconds (2f);
isPause = false;
resumeMenu.SetActive (false);
}
public void Resta ()
{
StartCoroutine (Restart ());
}
IEnumerator Restart ()
{
anim1.SetBool ("Rem", false);
anim1.SetBool ("Rev", true);
anim.SetBool ("IsRM", false);
yield return new WaitForSeconds (2f);
isPause = false;
Application.LoadLevel ("Play");
}
public void Men ()
{
StartCoroutine (Menu ());
}
IEnumerator Menu ()
{
anim1.SetBool ("Rem", false);
anim1.SetBool ("Rev", true);
anim.SetBool ("IsRM", true);
yield return new WaitForSeconds (2f);
isPause = false;
Application.LoadLevel ("MainMenu");
}
}