using UnityEngine;
using System.Collections;
using UnityEngine.UI;

[RequireComponent (typeof(Toggle))]
public class ToggleOnOffSoundPlayer : MonoBehaviour
{
	public AudioClip onSound;
	public AudioClip offSound;

	// Use this for initialization
	void Start ()
	{
		var toggle = this.GetComponent<Toggle> ();
		toggle.onValueChanged.AddListener (delegate(bool value) {
			if (value == true) {
				AudioManager2D.instance.PlaySound (this.onSound);
			} else {
				AudioManager2D.instance.PlaySound (this.offSound);
			}
		});
	}
}
