コード例 #1
0
        public void ProduceCatSound(Transform source, AudioArgument argument)
        {
            AudioObject audioObject = Instantiate(catAudioPrefab, source.position, source.rotation)
                                      .GetComponent <AudioObject>();

            audioObject.StartAudio(argument);
        }
コード例 #2
0
 public void StartAudio(AudioArgument argument)
 {
     _audioSource        = GetComponent <AudioSource>();
     _audioSource.volume = Random.Range(
         Math.Min(argument.minRandomVolume, argument.maxRandomVolume),
         Math.Max(argument.minRandomVolume, argument.maxRandomVolume));
     _audioSource.pitch = Random.Range(
         Math.Min(argument.minRandomPitch, argument.maxRandomPitch),
         Math.Max(argument.minRandomPitch, argument.maxRandomPitch));
     _audioArgument = argument;
     _audioSource.Play();
     _audioStarted = true;
 }