using System.Collections; using System.Collections.Generic; using UnityEngine; public class AquariumManage : MonoBehaviour { // Start is called before the first frame update public SCButton moguyuButton, jiaohuButton, bigshellsButton; // public Animator moguiyu,jiaohu,bigshells; public Animator mgy; public GameObject moguyuTeXiao; public AudioSource kunAudio; // private AudioSource audiosource; private bool isPlay; public bool IsPlay { get => isPlay; set { isPlay = value; // StartCoroutine(PlayMusic()); } } void Start() { // audiosource = this.gameObject.GetComponent(); StartCoroutine(PlaykunAudio()); moguyuButton.onClick.AddListener(() => { moguyuButton.gameObject.GetComponent().SetBool("Open", true); mgy.SetBool("Open", true); moguyuTeXiao.gameObject.SetActive(true); }); jiaohuButton.onClick.AddListener(() => { JiaohuManage(); }); bigshellsButton.onClick.AddListener(() => { BigshellManage(); }); } /// /// 每8秒琨叫一次 /// /// IEnumerator PlaykunAudio() { while (true) { yield return new WaitForSeconds(8f); kunAudio.Play(); } } public void JiaohuManage() { jiaohuButton.gameObject.GetComponent().Play("jiaohu"); } public void BigshellManage() { bigshellsButton.gameObject.GetComponent().Play("Take 001 0"); } //public IEnumerator PlayMusic() //{ // yield return new WaitForSeconds(10f); // audiosource.Play(); // IsPlay = true; //} }