| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class AudioMgr : MonoBehaviour
- {
- private static AudioMgr _instance;
- //µ¥Àû
- public static AudioMgr instance
- {
- get
- {
- if (_instance == null)
- {
- GameObject goR = Resources.Load<GameObject>("Prefabs/AudioMgr");
- GameObject AudioMgr = Instantiate(goR);
- _instance = AudioMgr.AddComponent<AudioMgr>();
- }
- return _instance;
- }
- }
- private AudioSource music;
- private AudioSource sound;
- private void Awake()
- {
- music = transform.Find("Music").GetComponent<AudioSource>();
- sound = transform.Find("Sound").GetComponent<AudioSource>();
- //Çл»³¡¾°²»Ïú»Ù
- DontDestroyOnLoad(this);
- }
- public void PlayBGM()
- {
- music.Play();
- }
- public void PlaySound()
- {
- sound.Play();
- }
- }
|