Пример #1
0
        public async void Awake()
        {
            Instance = this;

            //初始化加载一次

            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            await resourcesComponent.LoadBundleAsync("sound.unity3d");

            _musicMute = PlayerPrefs.GetInt("MusicMute", 0) == 1;
            _soundMute = PlayerPrefs.GetInt("SoundMute", 0) == 1;

            _soundVolume = PlayerPrefs.GetFloat("SoundVolume", 0.5f);
            _sfxVolume   = PlayerPrefs.GetFloat("SFXVolume", 1);

            root = new GameObject("SoundDatas").transform;
            GameObject.DontDestroyOnLoad(root.gameObject);

            if (_soundVolume > 0.5f)
            {
                _soundVolume = 0.5f;
            }

            //组件初始化完成后,直接调用播放背景音乐的方法
            this.PlayMusic("SoundBgHall", 0, _soundVolume, true);

            //注册按钮默认点击音效
            ButtonClickSound.RegisterPlayButtonSound();
        }
Пример #2
0
        public void Awake()
        {
            Instance = this;

            _musicMute = PlayerPrefs.GetInt("MusicMute", 0) == 1;
            _soundMute = PlayerPrefs.GetInt("SoundMute", 0) == 1;

            root = new GameObject("SoundDatas").transform;
            GameObject.DontDestroyOnLoad(root.gameObject);
        }