Пример #1
0
        private void PreviewSound(float volume, AudioType audioType)
        {
            if (Pair == null && m_uiEngine.ActiveModule != InputModule.STANDALONE)
            {
                return;
            }

            if (Pair != null && m_uiEngine.ActiveModule != InputModule.OCULUS)
            {
                return;
            }

            var audioSource = m_audio.GetAudioSource(audioType);

            if (audioSource.isPlaying)
            {
                audioSource.volume = volume;
                return;
            }

            var sampleSounds = m_commonResource.GetResource(GetResourceType(audioType), SampleSound);

            if (sampleSounds == null || sampleSounds.Length == 0)
            {
                return;
            }

            AudioClip sampleClip = ((AudioResource)sampleSounds[0]).Clip;
            AudioArgs args       = new AudioArgs(sampleClip, audioType)
            {
                FadeTime = 0
            };

            m_audio.Play(args);
            if (audioType == AudioType.SFX)
            {
                audioSource.loop = true;
            }

            m_playingSampleType = audioType;
        }
Пример #2
0
        public void OnMenuClose()
        {
            if (Selection.ExperienceType == ExperienceType.MANDALA && m_experienceMachine.CurrentExperience == ExperienceType.MANDALA && Selection.VoiceOver == null)
            {
                m_experienceMachine.GetExperience(ExperienceType.MANDALA).ResumeGuide();
                return;
            }

            if (!Experience.AudioSelectionFlag && m_lastVo != null)
            {
                AudioSource audioSource = m_audio.GetAudioSource(AudioType.VO);

                if (audioSource.isPlaying)
                {
                    float     lastTime = m_lastVo.Time;
                    AudioArgs args     = new AudioArgs(null, AudioType.VO)
                    {
                        FadeTime = .5f,
                        Done     = () =>
                        {
                            AudioArgs voArgs = new AudioArgs(Selection.VoiceOver, AudioType.VO);
                            voArgs.FadeTime   = 2;
                            voArgs.ResumeTime = lastTime;
                            m_audio.Resume(voArgs);
                        }
                    };
                    m_audio.Stop(args);
                    m_lastVo = null;
                }
                else
                {
                    AudioArgs voArgs = new AudioArgs(Selection.VoiceOver, AudioType.VO);
                    voArgs.FadeTime   = 2;
                    voArgs.ResumeTime = m_lastVo.Time;
                    m_audio.Resume(voArgs);
                    m_lastVo = null;
                }
            }
        }