2D Toolkit Forum

2D Toolkit => Support => Topic started by: habitoti on October 20, 2013, 09:53:31 am

Title: Audio Volume
Post by: habitoti on October 20, 2013, 09:53:31 am
Hi,

I found that click sounds that I attach to UI buttons have a very low volume only. Of course I can start to play with the global listener volume or the source volume, but thinking about it I just wondered: do orthographic cameras have an impact on the listener volume? I.e.: if I have high res graphics and a lower res device (so that the camera is logically farther away), does that change the overal volume then, because the audio source are more distant to the listener? Or is that all completely irrelevant? Sorry if this is a no brainer, I am just starting to connect the dots...

Thanks, habitoti
Title: Re: Audio Volume
Post by: unikronsoftware on October 20, 2013, 11:32:29 am
There is only one audio source - attached to the tk2dUIAudioManager script. The audio clip is 2D, so it shouldn't be dependent on your camera. If you decide to replace the clips, be sure to untick "3D sound" on it.
Title: Re: Audio Volume
Post by: habitoti on October 20, 2013, 11:41:08 am
Excellent...that was exactly the issue. Turning 3D off makes it sound as it should (too bad that can't be done as a mass operation :-/ -- I have a lot of audio pieces...)

Thanks, habitoti
Title: Re: Audio Volume
Post by: XpandeR on October 20, 2013, 09:10:31 pm
Quote
(too bad that can't be done as a mass operation :-/ -- I have a lot of audio pieces...)

You can do this for all sounds by implementing custom import preprocessor. Once this is done, you can reimport all existing audio. For new files, it will be set by default.

Something like this (save as ImportPreProcessor.cs and put into folder called Editor):

Code: [Select]
public class ImportPreProcessor : AssetPostprocessor
{
    private void OnPreprocessAudio()
    {
        var audioImporter = (AudioImporter)assetImporter;
        audioImporter.threeD = false;
    }
}
Title: Re: Audio Volume
Post by: habitoti on October 20, 2013, 09:20:46 pm
Excellent tip, 1k thanks!!