Commit 83d24a6b authored by 王雪伟's avatar 王雪伟

加入AudioManager

parent 5124f88f
...@@ -2,20 +2,23 @@ ...@@ -2,20 +2,23 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class AudioManager : MonoBehaviour public class AudioManager : MonoBaseMgr<AudioManager>
{ {
private GameObject PlayMusic;
private AudioSource mAudiSource; private AudioSource mAudiSource;
public static AudioManager Instance;
private void Awake() private void Awake()
{ {
Instance = this; mAudiSource = PlayMusic.AddComponent<AudioSource>();
mAudiSource = GetComponent<AudioSource>();
} }
public IEnumerator LoadAudio(string recordPath) public void PlayAudio(string MusicUrl)
{
StartCoroutine(LoadAudio(MusicUrl));
}
private IEnumerator LoadAudio(string MusicUrl)
{ {
// www 加载音频 // www 加载音频
WWW www = new WWW(recordPath); WWW www = new WWW(MusicUrl);
yield return www; yield return www;
var clipTemp = www.GetAudioClip(); var clipTemp = www.GetAudioClip();
mAudiSource.clip = clipTemp; mAudiSource.clip = clipTemp;
...@@ -25,7 +28,7 @@ public class AudioManager : MonoBehaviour ...@@ -25,7 +28,7 @@ public class AudioManager : MonoBehaviour
} }
private void Update() private void Update()
{ {
Debug.unityLogger.Log("是否暂停"+ mAudiSource.isPlaying); //Debug.unityLogger.Log("是否暂停"+ mAudiSource.isPlaying);
} }
public void StopPlay() public void StopPlay()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment