Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: AnimationMerc on May 21, 2014, 11:33:03 PM
-
Hi,
I'm getting started with NGUI and am trying to figure out the details of OnDragOver. I see how it works normally with the OnDrag function on a UIButton (some UI element needs to be selected before dragOver works) but I would like to have it function regardless of what was clicked first. Is there a way to do this?
The end goal is to make a context menu that pops up under the cursor when the LMB is pressed. The button would be selected (OnDragOver/OnDragExit, used like Hover) and activate by the LMB being released (OnPressUp). The exact menu that pops up would depend on what is under the LMB when pressed down. Is OnDragOver even the right way to go about this?
Thanks!
-
If you set UICamera.genericEventHandler to some game object, that game object's scripts will be receiving a copy of all events, whether they were handled or not. So if you wanted to receive OnDragOver / OnDrag / OnDragOut notifications in a single place, make use of the generic event handler.
-
Great, thanks for the help. I'll give it a shot this weekend.
-
That did the trick! Thank you.
-
Well, it worked but led the way to the next problem:
The UIbutton script now registers the Press command (changes color) after the GenericEventHandler was added.
I added a UIEvent Trigger to the button so I could have OnRelease notify but it nothing happens (the UIButton's OnClick does nothing either). Interestingly, I am getting my desired functionality with OnDragOut (mouse down over a non NGUI object, button pops up, drag mouse over then drag mouse off) but I can't get it to register an OnClick or OnRelease.
Any ideas?
-
All I can suggest is debug it, because it works just fine on a regular button.
-
Ok, thank you.