/// <summary> /// 对象池 声音 /// </summary> public void PoolAu(Vector3 pos, string key, float volume = 1, bool playOnAwake = false, bool loop = false) { AudioSource au = Pools.instance.CreateObject(1, audioSource.gameObject, pos, Quaternion.identity).GetComponent <AudioSource>(); au.clip = audioClip_Dic[key]; au.volume = volume; au.playOnAwake = playOnAwake; au.loop = loop; AudioEvent ae = new AudioEvent(); if (au.gameObject.GetComponent <AudioEvent>() == null) { ae = au.gameObject.AddComponent <AudioEvent>(); } float length = au.clip.length; Debug.Log(length); au.Play(); // ae.HideMySelfAu(au.clip.length); StartCoroutine(ae.AudioPlayFinished(0.2f)); }