Author Topic: OnTooltip  (Read 13619 times)

Shelt

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
OnTooltip
« on: April 16, 2012, 03:34:42 AM »
Hi!
I've a couple of gui elements that triggers a tooltip when hover them after 0.2 sec. It was a couple of weeks before I worked with them the last time, today however I noticed that they all got visible even though I was constantly moving the mouse; meaning OnTooltip still gets called even if the mouse is in movement. From the comment for the OnTooltip event it states that it should only be called if the mouse hovers over a collider for some time without moving.

Has this been changed for NGUI or is it me that have messed something up?

*EDIT*
I come up with another question as well. Is it possible in a smooth way to Anchor a Tooltip to a gameobject. Im working on a tooltip script that allows you to specify if the tooltip should be displayed Top, TopLeft, TopRight, Left... etc. from the gameobject which the script is attached to. Currently its a real fuzz to calculate the screen position of the gameobject, the screen size of the gameobjects boundary box, the Tooltip screen size and from there set the Tooltip Position.

Any thoughts on how to solve this without doing massive calculations?



Thanks,
Shelt
« Last Edit: April 16, 2012, 08:58:02 AM by Shelt »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #1 on: April 16, 2012, 09:23:40 AM »
I haven't touched tooltips, nope. Check your camera to make sure that the delay is still 0.2 and not 0.

No, there is no easier way. Anchor works with screen coordinates, and not with game objects.

Shelt

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: OnTooltip
« Reply #2 on: April 17, 2012, 01:27:32 AM »
I have to get back to you on this Aren; still having issues with OnTooltip.

Even if I create a new project, import NGUI and open your example scene with the character and inventory, I still get this issue with OnTooltip still being called even if I constantly move my mouse.

I have tried narrow the problem down and found out that the code never gets into this if-statement in the UICamera.cs

  1. if (i == 0 && currentTouch.pos != lastTouchPosition)
  2. {
  3.         if (mTooltipTime != 0f) mTooltipTime = Time.realtimeSinceStartup + tooltipDelay;
  4.         else if (mTooltip != null) ShowTooltip(false);
  5.         currentTouch.pos = lastTouchPosition;
  6. }
  7.  

When debugging it seems currentTouch.pos is always the same as lastTouchPosition, preventing the timer from reseting, which it should when the mouse is in constant moving.

There still might be some problems on my side, but seems so strange that I get the same issue if I create a new project and import NGUI and just try out the tooltip in your character scene...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #3 on: April 17, 2012, 04:29:31 AM »
The inventory example doesn't have any issues for me... tooltips come up after a second as expected.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #4 on: April 17, 2012, 04:47:34 AM »
Oh wait, I see what you mean. Moving the mouse doesn't cancel the tooltip. Yeah, lemme fix that.

KeithT

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 55
    • View Profile
Re: OnTooltip
« Reply #5 on: April 17, 2012, 05:36:46 AM »
Aren, is there any chance of you posting an example of how to attach an NGUI widget to a 3D object, as we have this requirement as well and have been hunting for a good approach for a while.

I had a look at windward and see you do it in there..............

Thanks

Keith

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #6 on: April 17, 2012, 05:38:38 AM »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #7 on: April 17, 2012, 05:40:25 AM »
The system in Windward is a fair bit more advanced, and all HUD elements are drawn in a single draw call. Plus the labels get re-used rather than re-created, and quite a few other tricks.

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
Re: OnTooltip
« Reply #8 on: October 30, 2012, 06:01:35 AM »
Is this fixed, with tooltip still showing when mouse is moved?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #9 on: October 30, 2012, 08:00:37 AM »
Yeah.

gryph

  • Guest
Re: OnTooltip
« Reply #10 on: May 17, 2013, 02:16:22 PM »
Apologies for resurrecting an old topic; but I'm experiencing the same issue with tooltips not disappearing.

Using NGUI Full v2.5.1

Is it a simple code change in UICamera that fixed this initially, or something like

  1. void OnTooltip (bool show)
  2.         {
  3.                 InvGameItem item = show ? mItem : null; //<<"borrowed" from CharacterX demo; no clue how this actually works...
  4.  
  5.                 if (item != null)
  6.                 {
  7.                         UITooltip.ShowText("TOOLTIP!");
  8.                 }
  9.                 UITooltip.ShowText(null);
  10.         }

...clearly pseudo coded, as the compiler got angry about me treating lastTouch as a boolean - not sure where to go from there

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnTooltip
« Reply #11 on: May 18, 2013, 05:52:18 AM »
'show' tells you whether the tooltip should be shown (true) or hidden (false).

Also keep in mind only the latest version of NGUI is supported. 2.5.1 is out of date.