12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlaySounds : MonoBehaviour
- {
- private AudioSource sound;
- public string soundName;
- private float isDestroyTimer;
- void Start()
- {
- // isLoopSound = false;
- sound = this.GetComponent<AudioSource>();
-
- PlaySound();
-
- }
- void Update()
- {
-
- //isDestroyTimer -= Time.deltaTime;
- //if (isDestroyTimer <= 0)
- //{
- // //Destroy(this.gameObject);
- //}
-
- }
- // Update is called once per frame
- public void PlaySound()
- {
- if (sound != null)
- {
- StartCoroutine(LoadDll2.DownLoadAssets((AssetBundle ab) =>
- {
- AudioClip obj = ab.LoadAsset<AudioClip>("SCAudiosConfig");
- sound.clip = obj; // (AudioClip)Resources.Load(soundName, typeof(AudioClip));//调用Resources方法加载AudioClip资源
- sound.Play();
- }));
- // isDestroyTimer = sound.clip.length;
- }
- }
- }
|