x


Why does my audio cut out completely when I try to edit volume? (Java) SOLVED!

Hi,

I have begun to implement a menu into my game (using Java), and it was working fine until I started to make a 'volume' option. I added an audio clip (I made sure it was 2D) to the scene as reference, and it worked fine until I put these sections of code into the menu and the camera (where the audio listener was) respectively:

private var volumeLevel = 1.0;

    volumeLevel = GUI.VerticalSlider(Rect(Screen.width/2,Screen.height/2-10,10,95), volumeLevel, 1.0, 0.0);

function update()
{
    PlayerPrefs.SetFloat ("Volume Level", volumeLevel);
}

The above (plus some GUI things) went into the Menu Script;

function Update () 
{
AudioListener.volume = (PlayerPrefs.GetFloat("Volume Level"));
}

The above went into my camera.

As soon as I put that into effect, no sound whatsoever worked. I changed the volume levels from 1 to 100, and still nothing. I also changed it from AudioListener.volume to audio.volume and put it in the source itself, but it still was silent. When I deleted the scripts again however, the audio worked perfectly fine again.

Is there something obvious I'm missing??

more ▼

asked Oct 04 '10 at 04:25 AM

Kristov gravatar image

Kristov
175 14 16 21

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I think this is an exceedingly simple fix--Change the 'update' function to 'Update' (with a capital U) in your menu script.

more ▼

answered Oct 04 '10 at 05:44 AM

Adam Rademacher gravatar image

Adam Rademacher
1.1k 1 3 19

I KNEW it had to be something stupid. It's the little things I never notice. Embarrassing, but I'm glad it's fixed now. Thanks a lot!

Oct 04 '10 at 07:28 AM Kristov
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3568
x1059
x78

asked: Oct 04 '10 at 04:25 AM

Seen: 962 times

Last Updated: Oct 04 '10 at 07:29 AM