示例#1
0
        public void Init()
        {
            autoListener = new GameObject("GameFramework.MusicModule");
            Object.DontDestroyOnLoad(autoListener);
            autoListener.AddComponent <AudioListener>();

            audios = new List <AudioSource>();

            GameObject _bgm = new GameObject("bgm");

            UtilityUnity.SetParent(_bgm, autoListener);
            bgm      = _bgm.AddComponent <AudioSource>();
            bgm.loop = true;

            Refresh();
        }
示例#2
0
        public void PlayAudio(AudioClip _audio)
        {
            AudioSource _as  = null;
            GameObject  _new = PoolModule.instance.Pop <GameObject>("AUDIO_PLAYER");

            if (_new == null)
            {
                _new = new GameObject(_audio.name);
                _as  = _new.AddComponent <AudioSource>();
            }
            else
            {
                _new.SetActive(true);
                _as = _new.GetComponent <AudioSource>();
            }
            UtilityUnity.SetParent(_new, autoListener);
            _as.clip = _audio;
            _as.mute = !PersistenceData.GetPrefsDataBool(CommonKey.SWITCH_AUDIO, true);
            _as.Play();
            Refresh();
            audios.Add(_as);
        }
示例#3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     UtilityUnity.SetParent(gameObject, lastFather);
     MessageModule.instance.Recevive(eventKeyName, MessageType.EventEndDrag, gameObject);
 }
示例#4
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     MessageModule.instance.Recevive(eventKeyName, MessageType.EventBeginDrag, gameObject);
     lastFather = parent.gameObject;
     UtilityUnity.SetParent(gameObject, tempFather);
 }