I have been struggling with the new UI system trying to figure out a way to use C# to make a single button toggle an animation on and off with the sound. I currently can get the new UI system to work what I want with two buttons, one button turns off the animation and the other turns it back on but ideally I want to just use one button to toggle the animation and sound on and off.
This is the code I have been using for each button to call to. Is there a simple way to do this with just one button?
using UnityEngine;
using System.Collections;
public class UIManagerScript : MonoBehaviour {
public Animator LEDlights;
public void StopLEDLightsAnimation()
{
LEDlights.SetBool("isPlaying", true);
}
public void PlayLEDLightsAnimation()
{
LEDlights.SetBool("isPlaying", false);
}
}