playMaker

Author Topic: Setting up uGUI toggle for mute button  (Read 6330 times)

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Setting up uGUI toggle for mute button
« on: October 27, 2015, 09:27:22 PM »
I'm just starting to use Playmaker with uGUI, but obviously not quite understanding it. Screenshot shows the first two actions in a simple FSM--this is for an audio mute button (that deactivates the Audio Listener on the Main Camera). But it doesn't seem to do anything. The toggle responds to a click, but that's just the basic uGUI toggle function. The FSM isn't responding to the click. Can anyone tell me what I'm  doing wrong?

TIA!
Dave

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Setting up uGUI toggle for mute button
« Reply #1 on: October 28, 2015, 03:31:05 AM »
Hi,
You should set toggle in this way :



You can put anything you want to toggle in toggle on and off state ofc.
and the send event does not need the UGUI / ONCLICK transition :)

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #2 on: October 28, 2015, 10:31:42 AM »
Thanks so much! But I'm stuck already--on the uGUI Toggle On Click Event, there is no "toggled" option among the many different Add Transition options for uGUI. I've checked all the submenus when I right-click on the Action in the FSM. How do I add that?

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #3 on: October 28, 2015, 10:35:33 AM »
And on the "Toggle is on" action, I can't find the "is on" and "is off" transitions either...

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #4 on: October 28, 2015, 10:38:21 AM »
And, on the Set Property actions, I've assigned the button with the Toggle script attached to it, but the readout on the action says "UnityEngine.GameObject" rather than "UnityEngine.UI.Toggle" as in your screenshot. Here is my Button inspector--is something missing on it?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Setting up uGUI toggle for mute button
« Reply #5 on: October 28, 2015, 11:19:55 AM »
Hi,

 you have to create the "is on" and "is off" transition event yourself. Go to the Even tab of the PlayMaker editor for your fsm, and click on "add event". then you'll find them events in your transition menu when wanting to add transition to a state.

 Bye,

 Jean

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #6 on: October 28, 2015, 01:03:29 PM »
Thanks much! Now I think I have it all set up properly...but it doesn't work. I click the toggle, but the FSM still shows "Wait for Click" on the first state. I'm obviously missing something, but where? On the Button inspector? Here's a screenshot of that also.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Setting up uGUI toggle for mute button
« Reply #7 on: October 29, 2015, 03:53:10 AM »
Hi,
do you have the toggle component on your object?

if you have the button component on it, remove that, then click on add component and search for toggle and add that to your object.

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #8 on: October 29, 2015, 09:18:53 AM »
Thanks for the reply!

The toggle GUI object has Canvas Renderer, Image, and Toggle scripts attached (you can see them in the screenshot in my previous post).

Does anything need to be assigned to "On Value Changed (Boolean)", on the Toggle inspector?

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #9 on: October 29, 2015, 09:53:49 AM »
I've tried a number of different things for On Value Changed (Toggle.Enabled, Toggle.isOn, PlayMakerFSM.SendEvent "toggled") but none work. And I can't find any information about how to configure that for PlayMaker. Must be simple, right? I just can't figure out what it should be....

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Setting up uGUI toggle for mute button
« Reply #10 on: October 29, 2015, 06:24:24 PM »
Hi,
i made i quick video (sorry no sound, i was in a crowded place)


gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #11 on: October 29, 2015, 10:06:07 PM »
Thank you so much for your help, I really appreciate it. Unfortunately, my FSM appears to be exactly like yours, except mine does not work. Clicking the toggle does nothing--never advances to the next state. I have watched your video six times, and cannot see any difference. Here is a screenshot of that first FSM state. Something is wrong, since the toggle is not recognizing a Click. Can you spot what I am doing wrong?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Setting up uGUI toggle for mute button
« Reply #12 on: October 30, 2015, 04:39:47 AM »
Hi,
What is the child of your Mute object (Button) is it text or an image?
If an image this might be overlapping your Mute object,
you can target your actions tho that object instead of use owner or transfer you fsm to that object and remove button script if there is one

gecko

  • Junior Playmaker
  • **
  • Posts: 52
Re: Setting up uGUI toggle for mute button
« Reply #13 on: October 30, 2015, 10:19:30 AM »
YES!! That was it! Thank you SO much for figuring this out for me. I really appreciate it!

(There was some weird--at least to me--conflicts between the Toggle functions and the FSM, so I finally set Toggle Transition to None and let the FSM handle everything, and now it works perfectly.)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Setting up uGUI toggle for mute button
« Reply #14 on: October 30, 2015, 02:28:59 PM »
Hi,
i am happy for you that it works now :)