Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class SomeScript : MonoBehaviour {
  2. public Animator ellen;
  3. void Start() {
  4. GetComponent<Button>().onClick.AddListener(delegate() {
  5. ellen.SetTrigger(0);
  6. });
  7. }
  8. }
  9.  
  10. public class SomeScript : MonoBehaviour {
  11. public Animator ellen;
  12. public float audioDuration;
  13. void Start() {
  14. GetComponent<Button>().onClick.AddListener(delegate() {
  15. StartCoroutine(TriggerAnimation());
  16. });
  17. }
  18.  
  19. IEnumerator TriggerAnimation() {
  20. ellen.SetTrigger(0);
  21. yield return new WaitForSeconds(audioDuration);
  22. ellen.ResetTrigger(0); //or however you want to return to the idle state
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement