示例#1
0
        /**
         * <summary>Gets, and creates if necessary, an AudioSource used for Narration speech. If the narratorSound variable is empty, one will be generated and its AudioSource referenced.</summary>
         * <returns>The AudioSource for Narration speech</returns>
         */
        public AudioSource GetNarratorAudioSource()
        {
            if (narratorAudioSource == null)
            {
                if (narratorSound != null)
                {
                    narratorAudioSource = narratorSound.GetComponent <AudioSource>();
                }
                else
                {
                    GameObject narratorSoundOb = new GameObject("Narrator");
                    UnityVersionHandler.PutInFolder(narratorSoundOb, "_Sounds");

                    narratorAudioSource = narratorSoundOb.AddComponent <AudioSource>();
                    AdvGame.AssignMixerGroup(narratorAudioSource, SoundType.Speech);
                    narratorAudioSource.spatialBlend = 0f;

                    narratorSound           = narratorSoundOb.AddComponent <Sound>();
                    narratorSound.soundType = SoundType.Speech;
                }
            }

            narratorSound.SetMaxVolume();
            return(narratorAudioSource);
        }
示例#2
0
        private void Awake()
        {
            if (surviveSceneChange)
            {
                if (transform.root != null && transform.root != gameObject.transform)
                {
                    transform.SetParent(null);
                }
                DontDestroyOnLoad(this);
            }

            if (GetComponent <AudioSource>())
            {
                audioSource = GetComponent <AudioSource>();

                if (audioSource.playOnAwake)
                {
                    isPlaying = true;
                    audioSource.playOnAwake = false;
                }
            }

            audioSource.ignoreListenerPause = playWhilePaused;
            AdvGame.AssignMixerGroup(audioSource, soundType);
        }
示例#3
0
        /**
         * <summary>Gets, and creates if necessary, an AudioSource used for Narration speech.</summary>
         * <returns>The AudioSource for Narration speech</returns>
         */
        public AudioSource GetNarratorAudioSource()
        {
            if (narratorAudioSource == null)
            {
                GameObject narratorSoundOb = new GameObject("Narrator");
                UnityVersionHandler.PutInFolder(narratorSoundOb, "_Sounds");

                narratorAudioSource = narratorSoundOb.AddComponent <AudioSource>();
                AdvGame.AssignMixerGroup(narratorAudioSource, SoundType.Speech);
                                #if UNITY_5 || UNITY_2017_1_OR_NEWER
                narratorAudioSource.spatialBlend = 0f;
                                #endif

                Sound narratorSound = narratorSoundOb.AddComponent <Sound>();
                narratorSound.soundType = SoundType.Speech;
                narratorSound.SetMaxVolume();
            }

            return(narratorAudioSource);
        }
示例#4
0
文件: Sound.cs 项目: IJkeB/Ekster1
        private void Awake()
        {
            if (surviveSceneChange)
            {
                DontDestroyOnLoad(this);
            }

            if (GetComponent <AudioSource>())
            {
                audioSource = GetComponent <AudioSource>();

                if (audioSource.playOnAwake)
                {
                    isPlaying = true;
                    audioSource.playOnAwake = false;
                }
            }

            audioSource.ignoreListenerPause = playWhilePaused;
            AdvGame.AssignMixerGroup(audioSource, soundType);
        }