playMaker

Author Topic: Recognizing when clicking the GUI?  (Read 2635 times)

Red

  • Hero Member
  • *****
  • Posts: 563
Recognizing when clicking the GUI?
« on: June 12, 2012, 06:41:36 PM »
I would like to know how i can get playmaker to recognize when the mouse is clicking on the GUI and find a way to filter that (so, as i have in my game if i have my inventory screen up and clicking on that to move items around or what, the spells won't trigger...)

basically, i want to find a way to make it so that the spells/weapons/etc will ONLY activate if i'm clicking on an exposed part of the screen and if i click on the GUI, the spells/weapons/etc will disregard the click.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Recognizing when clicking the GUI?
« Reply #1 on: June 13, 2012, 01:34:40 AM »
Hi,

 I think you have several solutions for this.

1: http://unity3d.qatohost.com/answers/163275/view.html
This means you define areas in your screen that are "GUI", if your gui happens to be flexible and can move and change in size, adjust them area to match.

2: instead of checking if you are over the gui, turn the problem the other way around. a spell should only be triggered if it's over the right type of object, using raycasting.

For your case, I think the first method will likely give you better result faster.

 bye,

 Jean

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Recognizing when clicking the GUI?
« Reply #2 on: June 16, 2012, 02:14:02 AM »
Thanks for this link, but I am very confused. I just don't get it for some reason.

From what I've experienced, GUI elements (PlayMaker and NGUI) seem to be part of a different camera and a different size than what you see in the main camera. Does the rectangle go inside the main camera or the GUI camera? Is this script something we can duplicate with PlayMaker actions? Or do we need to use the actual script somewhere? Is this something that can be used if you're dynamically generating GUI items, using PlayMaker actions like GUI Button?
« Last Edit: June 16, 2012, 02:18:01 AM by amaranth »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Recognizing when clicking the GUI?
« Reply #3 on: June 16, 2012, 09:40:07 AM »
Looks like i'll have to use the second option.

not sure if it's because of something that i've done wrong but the system won't recognize if it's clicking on a GUI through native means, even with something like a mouse-pick. so, option 2 won't do it.