playMaker

Author Topic: [SOLVED] A tooltip when hovering over a game object?  (Read 862 times)

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
[SOLVED] A tooltip when hovering over a game object?
« on: August 03, 2012, 09:51:20 AM »
Is there a way to make a tooltip which appears when hovering over a game object?  I've been hunting through the docs, but I'm not finding anything that makes sense.  Thanks!
« Last Edit: August 09, 2012, 01:50:59 PM by Netjera »

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object?
« Reply #1 on: August 03, 2012, 08:37:06 PM »
I found a workaround, but I'd still rather have some sort of action to do this better, if anyone knows of one?

Workaround

Go into Photoshop (or other art program).  Create a new blank layer.  Delete any background layers that are locked.  (If your text is black, you'll only need one layer.  If your text is white or some other light color, you'll want to make a dark background layer so that you can see it while you work.  This layer will be turned off when you export.)

Create your text.  Select it and crop so there is very little space around it.  Turn off your colored background, if you have one.  Save as a .png.  (I just used base settings in PS.)

Create an action on your state machine GUI -> Set Mouse Cursor.  Use the text png you just made as the image.  Do NOT check "Hide mouse cursor".  (If the mouse cursor is off, it will look like the text IS the mouse cursor.  With the mouse cursor on it looks like the text is following the mouse cursor.)

You'll want to do this for every object where you want a tooltip to appear, and make sure you size them so that the items are the size of the area where the tooltip should be. 

One problem I've noticed:  The png text seems to be resizing itself a little bit, and I don't know why.  The text is all the same size - 12 pt - but some tooltips look very clear and others look stretched or blurry.  Why???
« Last Edit: August 03, 2012, 08:40:12 PM by Netjera »

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #2 on: August 08, 2012, 05:01:45 AM »
Well, while my previous idea worked well enough, I did come across one problem:

While using the mouse cursor command to display the tooltip, I cannot also change the mouse cursor.  So, for example, when the mouse hovers over an object, it won't show a tooltip AND change the mouse cursor to a "grabby" hand, if it's something that can be picked up.  I'm already using the mouse cursor to display the text, and in order to show the grabby hand, I have to remove that or turn it off.

Please, does anyone know of any other way to show tooltip text, since I will need to use the mouse cursor command for actually changing the mouse cursor?  Thanks!

jeanfabre

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 3343
    • View Profile
    • Email
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #3 on: August 08, 2012, 05:43:39 AM »
Hi,

 you ought to find a more conventional way of displaying tooltip. Have you checked the Unity help, it has some example. The mouse cursor is not a solution because you do want eventually flexible tooltip content, so you should consider using a gui label.

check the action: GUILayout Begin Area Follow Object,
Code: [Select]
https://hutonggames.fogbugz.com/default.asp?W422
inside it put a gui layout label, and you'll have your tooltip system.


bye,

 Jean

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #4 on: August 08, 2012, 07:38:00 AM »
Thanks a lot, I'll have a look.  I played around with the GUI Labels, but couldn't figure out how to make them work, and the Unity help wasn't very.. helpful.. to someone new like me.  (I learned everything I know about Unity from Playmaker, lol.)

Thanks again!

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #5 on: August 08, 2012, 07:44:24 AM »
Okay, I *had* looked at this, I just hadn't understood how to use it.  Here are a few questions which the reference doesn't seem to answer, if anybody knows?

1)  Game object can be anything?  So I can embed the tooltip into the object itself, and not have to do anything with the mouse?

2)  If I use GUILayout Begin Area Follow Object, is GUILayout End Area required, or optional?  EDIT: Discovered this was mandatory or it gives you a GUI push/pop error.

3)  Finally, if I destroy the game object, will it also destroy the attached GUI?

If, for example, my object is at 0,0,0 and scaled 138,91,1; do I still have to set the offset for screen left and top?  Width and height of the area would be 138 and 91, yes? 

Thanks again!  I finally feel as if I'm on the right track!
« Last Edit: August 08, 2012, 09:51:07 AM by Netjera »

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #6 on: August 08, 2012, 09:50:02 AM »
I can't get this to work.  Is there a tutorial anywhere?  I've looked at the unity tutorials for making tooltips, but they're very confusing and don't really apply to what the Playmaker actions seem to be doing.  What are the steps for getting this to work please?

I've set it up as follows, but it's not showing any tooltip (I've tried putting it in Mouse Enter/Mouse Exit and in Mouse Over, with no results.)

1)  GUILayout Begin Area Follow Object :
GameObject (Object I want the tooltip to show up over)
Offset Left: 0
Offset Top: 0
Width: 38
Height: 115
Normalized: ON
Style: (Empty)

2) GUILayout Label:
Image: (None) <This is set up elsewhere>
Text: None
Tooltip: Firepot <This is the text I want to show when the player hovers over the item>
Style: (Empty)
Layout Options: (0)

3)  GUILayout End Area

If I put a text value into the "Text" field of GUILayout Label, it will display that text when I bring the mouse into the area, but then it doesn't disappear.  Obviously, I'm not setting it up properly.  Help please?

Are there any Playmaker tutorials for this?  I've been hunting the web and can't seem to find any examples of something which seems like it should be so easy!

jeanfabre

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 3343
    • View Profile
    • Email
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #7 on: August 09, 2012, 01:58:08 AM »
Hi,

 I think you have several issues, especially the "normalize" option. 32 when normalized, means 32 times the screen width or screen height! when normalized, values must be within 0-1 range to be visible on screen.

 I have attached a prefab with a working tooltip, study how it's been designed, it's very straight forward.

 Don't hesitate if you have more questions.

Bye,

 Jean
« Last Edit: August 09, 2012, 01:37:15 PM by jeanfabre »

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #8 on: August 09, 2012, 10:02:11 AM »
Hi,

 I think you have several issues, especially the "normalize" option. 32 when normalized, means 32 times the screen width or screen height! when normalized, values must be within 0-1 range to be visible on screen.

 I have attached a prefab with a working tooltip, study how it's been designed, it's very straight forward.

 Don't hesitate if you have more questions.

Bye,

 Jean

Jean,

Thanks so much for the help!  I'll have a look and see if I can figure it out!

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #9 on: August 09, 2012, 12:17:52 PM »
Is there any way to make the tooltip follow the mouse, instead of being in a static location?  In all respects, the tooltip works as I'd like - it's only showing the tooltip over an object that I define.  But instead of being shown in the same location relative to the object, I'd like it to be shown relative to the mouse.

Here's an example of what I mean from a commercial game. In the picture below, no matter where the mouse is over the object, it shows the tooltip centered and slightly above the mouse.


jeanfabre

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 3343
    • View Profile
    • Email
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #10 on: August 09, 2012, 01:36:41 PM »
Hi,

 ok, I did a special action for this, simply download the package again from the same post.

bye,

 Jean

Netjera

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: A tooltip when hovering over a game object? - UPDATED
« Reply #11 on: August 09, 2012, 01:50:21 PM »
Hi,

 ok, I did a special action for this, simply download the package again from the same post.

bye,

 Jean

OMG that's it!  Thank you thank you!

So it wouldn't do it without a custom action, then?  Thanks so much for putting one together!

jeanfabre

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 3343
    • View Profile
    • Email
Re: [SOLVED] A tooltip when hovering over a game object?
« Reply #12 on: August 09, 2012, 11:42:41 PM »
hi,

 Actually, you can, but that would be more cumbersome, and I think this is actually a good request for an action, that's why I made it.

bye,

 Jean.