playMaker

Author Topic: Canvas and Mouse Pick Issue [SOLVED]  (Read 2990 times)

Athin

  • Full Member
  • ***
  • Posts: 163
Canvas and Mouse Pick Issue [SOLVED]
« on: August 28, 2018, 07:22:45 AM »
Hey guys,

Got another problem I'm hoping someone can help with.  I'm using the Canvas for my UI currently.  What I'm trying to do is when the player clicks on the screen, a mouse pick action plays.  I have only 1 layer on the filter for UI (Which is what the Canvas is in) with a Bool to go true if it clicks on the UI.  Trouble is, the pick mouse doesn't seem to ever register it clicked on the canvas at all.  Is there an Action I'm missing or something I'm doing wrong?

Thanks
« Last Edit: September 15, 2018, 03:37:17 AM by Athin »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Canvas and Mouse Pick Issue
« Reply #1 on: August 29, 2018, 11:59:19 AM »
hi.

Mouse pick cant pick anything in the canvas

You can use a ui button resize it to the desired size and disable the image if needed or place a desired image.

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Canvas and Mouse Pick Issue
« Reply #2 on: September 11, 2018, 08:28:42 AM »
Hey Djaydino,

That solution wouldn't work for me sadly.  The canvas is constantly changing its buttons/icons depending on what the player clicks on. 

I found an old thread

http://hutonggames.com/playmakerforum/index.php?topic=10892.0

Sadly it seems the system I wanted to use with mousePick isn't possible.

The problem I have is that when the player selects a Unit, abilitiy buttons activate on the UI.  I have it set up currently that if they player left clicks anywhere while having a unit "selected"will deselect the unit where right clicking will move the unit to that location.  Problem is if they left click on the ability button while having a unit selected, they deselect and the button doesn't get press before getting deactivated.

What would be the best practice for this scenario to test the button press before deselecting the unit?
« Last Edit: September 11, 2018, 08:48:10 AM by Athin »

GonerGames

  • Junior Playmaker
  • **
  • Posts: 53
Re: Canvas and Mouse Pick Issue
« Reply #3 on: September 11, 2018, 01:21:54 PM »
So what is happening is that your Playmaker mousePick on left click event is firing before the raycast to the button UI hits. Best would be to disable the Playmaker left click action while the UI is open to prevent this.

As an idea:
1. When you left click on a unit it will open the UI overlay and turn on a bool to disable your Playmaker Mousepick event ie. Bool "Turn off mouse pick" - set true
1a. wherever your mouse pick event is located, have a bool test and a state that can temporarily disable this action
2. on the UI that opens have a transparent button across the entire screen that when left clicked on will deselect the unit, hide the ui and turn off "Turn off mouse pick" bool.
3. Have your buttons that you need sit on top of the transparent button so that they will fire off as you click them.

In short this will allow for the UI raycasts to hit the buttons. If you click away from the buttons then the transparent button will fire and re-enable your mousePick event.

This should not impact your right clicking for unit movement.




djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Canvas and Mouse Pick Issue
« Reply #4 on: September 11, 2018, 01:41:20 PM »
Hi.
I believe you can use something like pointer and when its over the ui object you can disable the mousepick.

I will do some testing in the next few days.
Could you make a short video or some images so i know what is happening and what should happen.

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Canvas and Mouse Pick Issue
« Reply #5 on: September 15, 2018, 03:37:00 AM »
Hey GonerGames,

That should do the trick from what you said. Did some quick testing on it and its a good work around that should be easy to set up!

Thanks so much for the help guys as always!