Playmaker Forum

PlayMaker News => General Discussion => Topic started by: pdunton on August 14, 2013, 05:03:19 PM

Title: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: pdunton on August 14, 2013, 05:03:19 PM
Hi!  I am creating a button, and have created three textures for it.  One for when the button is idle.  One for when the player has their mouse over the button.  And one for when the button is pressed. I can hook up the Idle and Pressed together by using GUIButton, and when pressed change the texture to Pressed, wait one second, and then reset the texture to idle.  But I have no idea how to change the texture when the mouse is over it. Any ideas?  Thanks!
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: jeanfabre on August 19, 2013, 03:36:26 AM
Hi,

 For this you will need to use the system events "MOUSE ENTER" and "MOUSE EXIT"

 have you tried this already?

bye,

Jean
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: Kothe on November 05, 2013, 02:18:02 PM
Hi
I am doing something like that for sounds over button,
but the MOUSE OVER doesn´t do anything, it works like MOUSE ETER.
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: pdunton on November 05, 2013, 10:59:45 PM
Im really sorry, but I do not know Playmaker very well.  I'm starting with a GUIButton that sets it to the Idle texture and I see a option where I can choose an event to send when clicked, but I have no idea what you are talking about from there.  Where do I look for system events and how do I aply them to this situation?
Thanks anyway!
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: jeanfabre on November 06, 2013, 01:01:33 AM
Hi,

 If you are starting with PlayMaker, you should grab a coffee ( or two :) ) and watch the  various screencasts and videos on PlayMaker, then these concepts will start to make sense and you'll be able to apply them then in your particular cases.

In your case:

1: Create a new event "MY BUTTON CLICK" and assign this event in your GUIButton action
2: Right click on the State and select "Add Transition", and navigate to that "MY BUTTON CLICK",
3: transit from this event to a new state, do something here, and come back to the original state using a "FINISH EVENT" or another custom event depending on what you want to do there.


2: don't use MOUSE OVER, it's advanced and generally not a good practice, prefer MOUSE ENTER and MOUSE EXIT and maintain a boolean flag "over", then you can check this bool value to know if the mouse is over or not,

Bye,

 Jean
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: Kothe on November 06, 2013, 06:22:27 AM
"prefer MOUSE ENTER and MOUSE EXIT and maintain a boolean flag "over", then you can check this bool value to know if the mouse is over or not,"

Can you explain it deeper

Thx
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: Kothe on November 06, 2013, 06:45:44 AM
...waiting, I got a cheap but functional trikc.

Using X and Y mouse position and making an area for the mouse in it, you can send an Event.

 ;)
Title: Re: Three State GUI Button (Idle, MouseHover, and Clicked)
Post by: jeanfabre on November 07, 2013, 02:13:57 AM
Hi,

 That's a good simple trick indeed and I would have recommanded to do that. IF your gui element doesn't move on screen that's fine.


As for the boolean flag, it only works with non unity gui elements, basically try with a Gui Texture, implement both global system events "MOUSE ENTER" and "MOUSE EXIT" on two separate state, "MOUSE ENTER" state raises to true the boolean flag and "MOUSE EXIT" state reset the flag to false. this way you know with this flag that the mouse is over the gui or not.

Does that explains better?

bye,

 Jean