Author Topic: Tooltip aligning/pivot issue with background and label  (Read 4443 times)

ajdickson1208

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Tooltip aligning/pivot issue with background and label
« on: November 18, 2014, 08:30:37 PM »
Hi, I'm not very smart and as there aren't a lot of tutorials for tooltip on NGUI, I'm trying to figure this out myself but failed.
First off, I'm not sure if I'm correct with the code.
  1. void OnTooltip(bool show)
  2. {
  3.         if (show) {
  4.                 UITooltip.ShowText("Tooltip");
  5.         }
  6.         else {
  7.                 UITooltip.Hide();
  8.         }
  9. }
I have this script attached to a GUI object with a box collider and it shows the tooltip and the background normally IF I have the pivot set to default, at the middle.

If I set the pivot to the top left for the label and the background, the background becomes a small dot on the top left of the label's position, but the label remains in the middle of the mouse cursor instead of being at the bottom right of the mouse cursor.

I apologize for my poor English, I hope someone could understand and tell me what I'm doing wrong, thanks.

Here's an image what I did.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tooltip aligning/pivot issue with background and label
« Reply #1 on: November 19, 2014, 03:42:27 PM »
Look at your transform position of the background. It's not (0, 0, 0). You have it at -57.

ajdickson1208

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Tooltip aligning/pivot issue with background and label
« Reply #2 on: November 19, 2014, 09:48:28 PM »
Thank you...>.<, proves my point, I'm not smart.
After changing my Label back to 0, 0, 0. and my background is anchored to the label with added border, there still seems to be a little problem with how the background sprite is displayed, I was wondering if you could help me with that, too?
It looked perfect before I hit the play button and the background would wrap nicely around the label.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tooltip aligning/pivot issue with background and label
« Reply #3 on: November 20, 2014, 06:32:37 PM »
The inspector looks fine to me this time. I suggest looking at the character inventory example that comes with NGUI. it uses a tooltip there. You could even copy/paste the whole thing into your game.

ajdickson1208

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Tooltip aligning/pivot issue with background and label
« Reply #4 on: November 20, 2014, 11:52:28 PM »
I have tried to follow that example exactly, I'll try again. Thanks for replying.