Author Topic: UITooltip.ShowText not showing anything  (Read 5762 times)

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
UITooltip.ShowText not showing anything
« on: November 27, 2013, 06:20:32 AM »
Attached this script to my button, and defined Tooltip via the Editor. Debug text appears, but the tooltip doesn't appear, not sure what I'm missing out on.

  1. public string Tooltip;
  2.  
  3. public void OnTooltip(bool show) {
  4.                
  5.                 if (Tooltip!=null && show) {
  6.                         Debug.Log("Show tooltip "+Tooltip);
  7.                         UITooltip.ShowText(Tooltip);
  8.                 }
  9.                 else {
  10.                         UITooltip.ShowText(null);
  11.                 }
  12.         }
  13.  

My structure:
UI Root (2D)
 - Camera
 - UI Panel
    - TooltipPanel (panel)
       - BaseTooltip (sprite)
       - LabelTooltip (label)

UITooltip is attached to TooltipPanel and defined BaseTooltip and LabelTooltip respectively. Camera left empty but no difference when defined.

Depth seems ok, TooltipPanel shows up in editor above everything else.

Any help or suggestions appreciated!

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #1 on: November 27, 2013, 06:24:05 AM »
Using 3.0.6 f4.

I checked that the tooltip sprite and label did some movements when the tooltip was triggered and when I selected them and could see the alpha going from 0 to 255 in the sprite inspector. No idea why it is not visible in the scene...?
« Last Edit: November 27, 2013, 08:26:38 AM by Nicky »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #2 on: November 27, 2013, 10:13:45 AM »
Is there a parent panel with alpha of 0?

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #3 on: November 27, 2013, 08:58:59 PM »
Checked the inspector when the app was running.

TooltipPanel has UIPanel with alpha=1

Other UIPanels alongside TooltipPanel were showing fine. I also checked that the UILabel was already populated with the correct text. Could see the label outline animating in the editor's scene view when I selected the label and sprite.

For UILabel and UISprite, checked the color under "Widget" and alpha was both 255.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #4 on: November 28, 2013, 01:11:22 AM »
Was anything animating from scale of 0? Which version of NGUI are you using? Have you tried hiding other panels to see where the tooltip is, in case something is covering it?

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #5 on: November 28, 2013, 08:50:19 PM »
Thanks for the reply!

Using 3.0.6 f4.

I found out what's wrong. When I called UITooltip.ShowText, the TooltipPanel's position.z is set to the same value as the position.z of the camera, even though it was placed under the UIPanel (z=0 in editor before UITooltip.ShowText was called). What's causing it and what can I do to change it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #6 on: November 29, 2013, 09:53:24 AM »
Z doesn't matter anymore in NGUI 3. Only depth matters. Make sure the depth of your tooltip panel is higher than others. That said, I don't see anything that would change the Z in the UITooltip. Nothing affects Z there as far as I can see.

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #7 on: December 26, 2013, 10:31:31 PM »
Attached screenshot of the inspector.

Before UITooltip.ShowText() is called, the tooltip panel was at (0,0,0)

After UITooltip.ShowText("some text") is called, the tooltip panel position changed to (-272,260,-663.5147)

I only just created the TooltipPanel, and don't have any code that alters the position of this panel. Is there anything else that might have been set wrongly?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #8 on: December 27, 2013, 04:03:47 PM »
What's your near and far clip planes on the Camera2D? NGUI uses -10 to 10 by default.

Nicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #9 on: December 29, 2013, 08:09:16 PM »
That fixed it! It was set to near 0 far 10. Thanks!

Next question is, is it possible to easily adjust the width of the tooltip sprite, and the position of the tooltip? Mine is completely covering the original button that I am hovering over now.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITooltip.ShowText not showing anything
« Reply #10 on: December 29, 2013, 08:21:46 PM »
It's up to you where the tooltip shows up. UITooltip has the positioning code in it. Look inside UITooltip.SetText.

Keep in mind you don't need to use UITooltip either. You can do what you want after receiving the OnTooltip notification.