Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Creating tooltips

Discussion in 'Immediate Mode GUI (IMGUI)' started by DiogoCosta, Mar 23, 2015.

  1. DiogoCosta

    DiogoCosta

    Joined:
    Feb 15, 2015
    Posts:
    12
    I'm creating a game and when I hover over something such as a button I would like a tooltip to be displayed, does anyone know how to do this?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    What button are you using ? The old GUI or the new UI that was released with Unity 4.6 ?
     
  3. DiogoCosta

    DiogoCosta

    Joined:
    Feb 15, 2015
    Posts:
    12
    The new GUI, I'm currently using version 5 of Unity
     
  4. Kogar

    Kogar

    Joined:
    Jun 27, 2013
    Posts:
    80
    Since many small thinks are already asked. A quick search can find many things. Currently 5. Position in the unity "search forums" with only one keyword "tooltips"
    http://forum.unity3d.com/threads/question-dynamic-tooltips.268172/#post-1780687
    Should give a nice starting point.

    Have reread my thread. Additionally you need to know what and how you want it to show.
    So you'll need a container(Canvas) in which you put your tooltip content and a fade in/out of the tooltip
    http://forum.unity3d.com/threads/how-to-tween-alpha-of-an-image.263925/#post-1785362
    To detect when your mouse hovers over a gameobject you need
    OnPointerEnter and OnPointerExit.
    Just put IPointerEnterHandler, IPointerExitHandler next to MonoBehaviour. So instead of
    Code (csharp):
    1. public class Tooltip : MonoBehaviour {}
    you write
    Code (csharp):
    1. public class Tooltip : MonoBehaviour , IPointerEnterHandler, IPointerExitHandler{
    2. public void OnPointerEnter(PointerEventData eventData) {//FadeIn}
    3. public void OnPointerExit(PointerEventData eventData) {//FadeOut}
    4. }
    and can use the OnPointerEnter/exit method

    If you don't want to write everything you can try one of the extension methods provided by other users. http://forum.unity3d.com/threads/tooltips.309636/#post-2015245
     
    Last edited: Mar 24, 2015