Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mTruly on February 26, 2016, 10:20:28 AM

Title: Unity Buttons Staying Highlighted [SOLVED]
Post by: mTruly on February 26, 2016, 10:20:28 AM
Not sure if this is a Playmaker issue but Playmaker is involved.

I have a setup where Playmaker sends events based on the pressing of Unity UI buttons.  All works fine with this but there is an issue where when the user clicks on the Unity UI button, the event is sent properly but the button remains in it's highlighted condition.  (see attached image).

Is there some way of forcing the button to return to it's normal condition?
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on February 28, 2016, 07:32:04 AM
There's got to be some way of making Unity buttons return to their Normal condition.

I found that there is a Canvas Force Update action and tried adding this but it made no difference... Unity buttons are staying highlighted.

Any ideas?

Thanks!
Title: Re: Unity Buttons Staying Highlighted
Post by: djaydino on February 28, 2016, 08:54:18 AM
Hi,
Are you using the "PlayMakerUGuiComponentProxy" Component?

Can you give some more information how you have setup you states with pictures if possible?
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on February 28, 2016, 09:10:40 AM
Thanks for the ideas!

I'm not using that component... I'll have to look into what it is.

The states are really simple and I'm using the U Gui Button On Click Event to send events from Unity buttons.  (See attached screengrab).

Thanks again.
Title: Re: Unity Buttons Staying Highlighted
Post by: Zeldag on February 28, 2016, 10:09:05 AM
I think that is a componenet that comes with the UGUI actions. Ive heard that you need to have it in the scene (or on the gui objects i cant rememeber). But to be honest all my uGUI actions always worked without it, not sure why...
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on February 29, 2016, 07:49:01 AM
Thanks for the ideas!

I tried adding that action to the states that contain the Button Send Event actions and also tried adding them directly to the Unity button objects themselves and all this made no difference... the buttons function fine but the highlighted condition remains after the buttons are clicked.  If I click on empty space somewhere, the highlighted button returns to it's normal condition.

Thanks again.
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on February 29, 2016, 08:09:23 AM
Another weird thing about this.

As in the image above, when the user clicks on the View A button, the proper event is sent but the button remains in its highlighted condition (instead of returning to the normal condition).

If the user uses any of the keyboard shortcuts for other (unrelated) functions... the highlighted UI button which was pressed earlier will change between highlighted and pressed and will return to the highlighted condition each time any keyboard shortcut is pressed.

Only if the user clicks the mouse somewhere else on screen will the highlighted button change back to normal.
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on March 01, 2016, 09:54:15 AM
Is there some way to trick the system to work properly?

For example, If I click anywhere on screen after using the Unity button... the button returns to it's normal color (as it should be doing).

Is there a way to send an empty click after each button press so the button is tricked into refreshing properly?

Thanks!
Title: Re: Unity Buttons Staying Highlighted
Post by: djaydino on March 01, 2016, 10:28:01 AM
Hi,
You should get the ugui proxy full package on the EcoSystem (https://hutonggames.fogbugz.com/default.asp?W1181) and check this tutorial out :

Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on March 01, 2016, 11:33:23 AM
Thanks very much for the info!

Unfortunately, that made no difference.

My button functionality is working fine currently... the only issue is that when the Unity button is clicked, it stays stuck on the highlighted color until the user clicks somewhere else... then the button color returns to the normal button color.

I recreated the tutorial steps precisely and get the exact same result... the clicked Unity button stays stuck on the highlighted color until the user clicks somewhere else... then the button returns to the normal color.

Latest Unity/latest Playmaker.

Thanks again.

Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on March 02, 2016, 08:00:15 AM
I tested this problem on a second computer and got the same result... Unity buttons are staying highlighted after having been clicked.
Title: Re: Unity Buttons Staying Highlighted
Post by: playsteven on March 02, 2016, 11:38:17 AM
Hey mTruly,

I make extensive use of uGui and especially buttons in my game and I've never ran in to any of the issues you describe.

Is it possible you could dropbox/google drive/anything else a very basic Unity project with the error present and I'll check on my system?

Steven
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on March 02, 2016, 03:15:46 PM
Sure I can share an example file... but I haven't really shared Unity/Playmaker projects yet so I'm not sure what the best way to share the example is?  Should I just post the Unity Scene or do I need to export a package?

Thanks!
Title: Re: Unity Buttons Staying Highlighted
Post by: playsteven on March 02, 2016, 04:31:34 PM
I was going to say upload the directory and PM me the link, but I realised it will contain the Playmaker directory and, although I obviously have a license, we would need permission from Alex or another member of the team.

[If Alex is reading and there is no issue, could you please say this is okay :) I totally understand if it is not.]

Otherwise, we'll just reproduce the steps :) Just number them and I'll follow them and we'll see if we get the same result. Just like ...

1) Create a new project
2) Import Playmaker
...

Bear in mind I'm not an expert like the other folks around here, but my game Mister Smith & His Adventures is nothing but buttons and there has never been an issue.

Might take a day or three of four to get back to you :)
Title: Re: Unity Buttons Staying Highlighted
Post by: djaydino on March 02, 2016, 05:11:56 PM
Hi,
you can share your whole project but without the Playmaker dll's

then when you open the project reinstall pm and it should work

or you can export the scene in a package but if there are things from your project that are needed (for example prefabs, custom action,...) you should include those when you export

What you also can do is make a video with your problem and show also all your states and actions that are involved.
Title: Re: Unity Buttons Staying Highlighted [SOLVED]
Post by: mTruly on March 02, 2016, 05:34:48 PM
Thanks for the guidance on this.  I don't want to be posting proprietary files by accident.

I went to export a package and got a file list with a bunch of checkboxes... and So I guess I should uncheck the entire PlayMaker folder?  Or is there a particular sub-folder?

Likewise I could easily attach or upload the scene file, but would that contain proprietary PlayMaker files?


Repro steps are simple:

1.  Start a new PM project.
2.  Add a Cube (cuz I like cubes)
3.  Add an EMPTY object.
4.  Add an PM FSM to EMPTY.
5.  Add a Unity Button.
6.  Add a 'uGui Button On Click Event' action to FSM on EMPTY.
7.  Point the uGui action to the Unity Button.
8.  Change the colors on the Unity Button to Normal=blue Highlighted=pink Pressed=yellow.
9.  Go to Play mode.
10.  Click the button.

For me (on 2 computers), the blue button highlights to pink when the mouse hovers over it, the user clicks and the button is yellow while mouse is down, then the button turns back to pink on mouse up and stays pink until the user clicks somewhere else on the screen.

Thanks again.
Title: Re: Unity Buttons Staying Highlighted
Post by: playsteven on March 02, 2016, 06:46:49 PM
[see my next post for possible solution]

Hey,

Couldn't sleep, so I've had a quick look at this. I'm on Unity 5.3.3f1 and Playmaker 1.80 f40.

It will be of no help, but I get exactly the same behaviour as you.

The highlighted colour works until you press the button. After the press the highlighted coloured sticks, even when you are not over the button and only returns to normal when you click somewhere else on the screen.

I installed Playmaker UGui prefab, so that's not the issue.

I wouldn't have noticed this as I only use buttons with images, and they don't highlight when hovered over (mine is a mobile game).

My guess, and as I said, my friend, I am an idiot and there are much smarter people on the forum than me, that it's not a Playmaker issue, it is either a Unity issue or a Unity setting.

I deleted all trace of Playmaker from the project, so I was left with only a canvas and a button, and the same issue is seen  ???

Hope that helps, at least a little :)

Now, to get some sleep!
Title: Re: Unity Buttons Staying Highlighted
Post by: playsteven on March 02, 2016, 06:51:27 PM
Actually, I thought I'd try one more thing before going to bed  ;D

Try setting the button's Navigation property (below the colours) to None :)

If you leave it at Automatic, the arrow keys navigate through the buttons, but since you've only got one button that's why you're seeing this effect?

Maybe, anyway ...

Now, really, sleep  :-[
Title: Re: Unity Buttons Staying Highlighted
Post by: mTruly on March 02, 2016, 07:35:05 PM
Thank you!  Excellent!  That setting seems to cure the problem at first glance... will test more tommorow.

Sleep well!

Thanks again.
Title: Re: Unity Buttons Staying Highlighted
Post by: playsteven on March 03, 2016, 01:06:59 AM
Superb, hope it stays fixed  8)