예제 #1
0
 void OnEnable()
 {
     if (source == null)
     {
         source = gameObject.AddComponent <AudioSource>();
     }
     AudioTrigger.configureSource(fx, source);
     source.loop = true;
     source.Play();
 }
예제 #2
0
        public void VolumeFade(AudioTrigger audioTrigger, AudioSource audioSource, float targetVol, float fadeTime) // configures and triggers the fade procedure
        {
            volFadeStart = vol;
            volFadePath  = targetVol * audioTrigger.volume - volFadeStart; // targetVol=1, the target is not 1, but is equal to volumeStart

            timeFadeDuration = fadeTime;
            timeFadeStart    = Time.time;

            if (volFade != null)
            {
                StopCoroutine(volFade);
            }

            volFade = VolFade(audioSource);
            StartCoroutine(volFade);
        }
예제 #3
0
        public static float configureSource(AudioTrigger trigger, AudioSource source, float volumeScale = 1f, float pitchScale = 1f)
        {
            source.clip = trigger.Clip;
            source.outputAudioMixerGroup = trigger.channel;
            source.volume = trigger.volume * volumeScale;
            if (trigger.useRandomPitch)
            {
                source.pitch = Random.Range(trigger.randomPitch.x, trigger.randomPitch.y) * trigger.pitch;
            }
            else
            {
                source.pitch = trigger.pitch * pitchScale;
            }


            source.spatialBlend = trigger.soundType == SOUND_TYPE.EMIT_3D ? 1f : 0f;
            source.minDistance  = trigger.minDistance;
            source.maxDistance  = trigger.maxDistance;
            return(source.clip != null ? source.clip.length + 0.5f : 0f);
        }
예제 #4
0
 public void triggerEffect(AudioTrigger fx)
 {
 }