playMaker

Author Topic: [SOLVED]sound on off toggle  (Read 10244 times)

arilarikins

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
[SOLVED]sound on off toggle
« on: January 24, 2013, 09:45:03 AM »
Hi...

I'd like to create a button that toggles the sound on and off in-game, swapping the texture to 'On' or 'Off' on the button each time it's clicked.

I've created a GUI button and used a texture in the GUI button options. Two states now toggle between each other, changing the graphic. I've used 'Audio Play' and Audio Stop' to control an audio source in the Playmaker GUI.

I used the following tutorial to achieve this:

Although this would be good for playing / stopping in-game music, the rest of the sounds still play. Does anyone know the correct way to disable all in-game sound, or should this be left to the device the game is being played on?

Many Thanks in advance,
Harry
« Last Edit: November 02, 2015, 03:48:02 AM by jeanfabre »

ArctheLad

  • Playmaker Newbie
  • *
  • Posts: 24
    • View Profile
Re: sound on off toggle
« Reply #1 on: February 07, 2013, 03:50:45 AM »
Hey there.

Perhaps try just turning off all of the sounds in your inspector panel, pre-pressing play, and just add some FSMs to the sounds that you want to control?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15318
  • Official Playmaker Support
    • View Profile
Re: sound on off toggle
« Reply #2 on: February 07, 2013, 11:49:23 PM »
Hi,

 turning everything sound off is simply a matter of disabling the "audio listener" component on your main camera ( likely).

else, you will need a framework of some sort to filter what kind of sounds you want to control ( background music, or in game sounds and effects, etc etc). You could use tags for example or better have a fsm on each gameObject responsible for sound to listen to user controls and shut down particular sounds based on the user query.

bye,

 Jean

arilarikins

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: sound on off toggle
« Reply #3 on: February 11, 2013, 10:12:53 AM »
Hey there.

Perhaps try just turning off all of the sounds in your inspector panel, pre-pressing play, and just add some FSMs to the sounds that you want to control?

Hi ArctheLad...

Not sure what you mean by pre-pressing play - I guess I only need to shut the total sound off / on for anyone without headphones that might want to play quietly.

Many thanks for the reply,
Harry

arilarikins

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: sound on off toggle
« Reply #4 on: February 11, 2013, 10:21:04 AM »
Hi,

 turning everything sound off is simply a matter of disabling the "audio listener" component on your main camera ( likely).

else, you will need a framework of some sort to filter what kind of sounds you want to control ( background music, or in game sounds and effects, etc etc). You could use tags for example or better have a fsm on each gameObject responsible for sound to listen to user controls and shut down particular sounds based on the user query.

bye,

 Jean

Hi Jean...

Yes, that sounds like what I'm after - I need to disable the audio listener - there doesn't seem to be anything in Playmaker to do that though. Is there a custom action anywhere that anyone knows of.

The other level of control isn't really neccessary, but thanks for addressing it for future use.

Many Thanks,
Harry

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15318
  • Official Playmaker Support
    • View Profile
Re: sound on off toggle
« Reply #5 on: March 18, 2013, 06:22:32 AM »
Hi,

 The audio listener is simply a component, so use the action "set property" drag the audiolistener component ( not the gameObject, really drag the audio listenre component itself), then select the "enable" property and turn that on and off.

bye,

 Jean

jerware

  • Playmaker Newbie
  • *
  • Posts: 23
    • View Profile
Re: sound on off toggle
« Reply #6 on: May 16, 2013, 10:40:40 PM »
The audio listener is simply a component, so use the action "set property" drag the audiolistener component ( not the gameObject, really drag the audio listenre component itself), then select the "enable" property and turn that on and off.

I just tried this and, oddly, it worked in the editor but not in my compiled game. I tried both "set property" and "enable behavior" actions. Both gave the same result. In order to mute all audio, I had to attach this script to my camera with the audioListener, and then invoke one of the two methods using the "invoke method" action.

Code: [Select]
#pragma strict

function muteAudio() {
AudioListener.pause = true;
}

function unmuteAudio() {
AudioListener.pause = false;
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15318
  • Official Playmaker Support
    • View Profile
Re: sound on off toggle
« Reply #7 on: May 16, 2013, 11:23:50 PM »
uhm, that's odd indeed.

Can you try this custom action? if that works I'll promote it to the new action forum section.

bye,

 Jean

Elizeusz

  • Playmaker Newbie
  • *
  • Posts: 32
    • View Profile
Re: sound on off toggle
« Reply #8 on: August 15, 2014, 11:03:42 AM »
Hi. This is old post anyway i had same problem. When i used set property and then enable disable audio listener all was working good in unity but not on mobile , i took Your action and all is ok.

gecko

  • Junior Playmaker
  • **
  • Posts: 52
    • View Profile
Re: sound on off toggle
« Reply #9 on: October 31, 2015, 05:36:59 PM »
I'm using the custom action above, but it doesn't work how I want. It really does seem to pause the audio, rather than mute/disable the audio listener -- so all audio clips that have been triggered after the Mute button was clicked are queued up, and they all play when you unmute the audio.

I think I'd be fine with simply disabling/enabling the audio listener, but I can't figure out how to drag that component specifically to the FSM state -- when I click on the Audio Listener GO, the FSM disappears from the Playmaker panel, so there's nowhere to drag it to...

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: sound on off toggle
« Reply #10 on: October 31, 2015, 07:27:25 PM »
Have you tried the action: AudiolistenersetVolume?
You can find it on the ecosystem....

gecko

  • Junior Playmaker
  • **
  • Posts: 52
    • View Profile
Re: sound on off toggle
« Reply #11 on: November 01, 2015, 01:19:38 PM »
Yes, that's what I want! Thank you so much!