Пример #1
0
        /// <summary>
        /// チャンネルの初期化
        /// </summary>
        private static void InitializeChannel(AudioSetting setting)
        {
            if (_isInitialized)
            {
                return;
            }
            PlayingChannelMap[AudioChannel.SE].Clear();
            PlayingChannelMap[AudioChannel.BGM].Clear();

            var initBgmVolume = ChannelVolumeMap[AudioChannel.SE];
            var initSeVolume  = ChannelVolumeMap[AudioChannel.BGM];

            var go = Instance.gameObject;

            for (var i = 0; i < setting.seChannelCount; i++)
            {
                PlayingChannelMap[AudioChannel.SE].Add(
                    new AudioInfo(go.AddComponent <AudioSource>())
                    .SetGlobalVolume(initSeVolume)
                    );
            }

            for (var i = 0; i < BgmPlayCount; i++)
            {
                PlayingChannelMap[AudioChannel.BGM].Add(
                    new AudioInfo(go.AddComponent <AudioSource>())
                    .SetGlobalVolume(initBgmVolume)
                    );
            }
        }
Пример #2
0
        /// <summary>
        /// 初期化
        /// </summary>
        public static void InitializeIfNeed(AudioSetting setting = null, IAudioResourceLoader loader = null)
        {
            if (_isInitialized)
            {
#if ENABLE_DEBUG_SHIBUYA24_AUDIO
                Debug.Log("Already Initialized");
#endif
                return;
            }

            if (setting == null)
            {
                setting = new AudioSetting();
            }

            InitializeChannel(setting);
            if (loader == null)
            {
                loader = new ResourcesLoader();
            }

            Loader = loader;

#if ENABLE_LOCALSAVE_SHIBUYA24_AUDIO
#if ENABLE_DEBUG_SHIBUYA24_AUDIO
            Debug.Log("Enable AudioLocalSave");
#endif
            // Apply Initialize LocalSetting
            SetVolume(AudioChannel.BGM, AudioLocalSave.GetVolume(AudioChannel.BGM));
            SetVolume(AudioChannel.SE, AudioLocalSave.GetVolume(AudioChannel.SE));
            SetMute(AudioChannel.BGM, AudioLocalSave.GetMute(AudioChannel.BGM));
            SetMute(AudioChannel.SE, AudioLocalSave.GetMute(AudioChannel.SE));
#else
#if ENABLE_DEBUG_SHIBUYA24_AUDIO
            Debug.Log("Disable AudioLocalSave");
#endif
#endif
            _isInitialized = true;
        }