public void Play(AudioFragment fragment, float pitch)
        {
            source.outputAudioMixerGroup = fragment.OutputGroup;
            source.clip  = fragment.AudioClip;
            source.pitch = pitch;

            source.Play();
        }
예제 #2
0
        //public static AudioClip GetClip(AudioClip source, float pitch, float speed)
        //{
        //    // Create a new AudioClipBaker to create the new AudioClip
        //    AudioClipBaker baker = new AudioClipBaker(source, pitch, speed);
        //    AudioClip newClip = baker.Bake();
        //    return newClip;
        //}

        public static AudioFragment GetFragment(string name)
        {
            Profiler.BeginSample("Fetch AudioFragment");
            AudioFragment fragment = INSTANCE.fragments.FirstOrDefault(x => x.Name == name);

            if (fragment == null && name != "")
            {
                Debug.Log("Cannot find the AudioFragment \'" + name + "\'");
            }

            Profiler.EndSample();
            return(fragment);
        }
예제 #3
0
        public AudioSourceInfo PlaySound(AudioFragment fragment, float pitch)
        {
            if (fragment == null)
            {
                return(null);
            }

            AudioSourceInfo source = GetSource();

            if (source == null)
            {
                source = new AudioSourceInfo(gameObject);
                sources.Add(source);
            }

            source.Play(fragment, pitch);
            return(source);
        }