How to Make A Simple Tooltip in Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 45

  • @IndicIndieGameDev
    @IndicIndieGameDev ปีที่แล้ว +2

    Thanks for a simple and clean implementation.
    Unlike some other popular unity devs that take you on a rabbit hole of "custom components > needs download > sign up with email to download > news letters" vicious cycle.

  • @helciowagner6101
    @helciowagner6101 ปีที่แล้ว +4

    Congratulations! Very straight to the point. I've seen other tutorials that are too long because they spend too much time explaining how to make a fancy tooltip box. I prefer this one.

  • @deadbroadcastpc
    @deadbroadcastpc 3 ปีที่แล้ว +7

    Damn dude loving the flow of videos coming out, great work

  • @danieller213
    @danieller213 2 ปีที่แล้ว +2

    Extremely useful, easy to follow, and easy to modify for any project. Thanks for this!

  • @ibelonghere
    @ibelonghere ปีที่แล้ว +1

    This is excellent! So many uses, and gives the game a way to interact with the player. Thank you.

  • @lalitsharma3137
    @lalitsharma3137 ปีที่แล้ว +16

    For those of you trying to use this on a Button instead of a GameObject the Tooltip Script would be different as shown below.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.EventSystems;
    public class Tooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    {
    public string message;
    //=======================================For GameObjects==================
    /*private void OnMouseEnter()
    {
    TooltipManager._instance.SetandShowToolTip(message);
    }
    private void OnMouseExit()
    {
    TooltipManager._instance.HideToolTip();
    }*/
    //=======================================For Buttons=========================
    public void OnPointerEnter(PointerEventData pointerEventData)
    {
    TooltipManager._instance.SetandShowToolTip(message);
    }
    public void OnPointerExit(PointerEventData pointerEventData)
    {
    TooltipManager._instance.HideToolTip();
    }
    }
    // This works 100%. Just set the Pivot correctly.

    • @itsPatticatti
      @itsPatticatti ปีที่แล้ว +2

      YOU ARE THE GOAT

    • @atnguyenhuu2730
      @atnguyenhuu2730 6 หลายเดือนก่อน +2

      Thanks!!!!

    • @its_nuked
      @its_nuked 6 หลายเดือนก่อน +2

      Thank you! We were just dealing with this with a friend, LIFESAVER!!!!
      I'm assuming this is because pointer is used for UI and mouse for game objects? ;D

    • @lalitsharma3137
      @lalitsharma3137 6 หลายเดือนก่อน

      @@itsPatticatti Thanks for that. 🇮🇳☺️😇

  • @yanderezaf
    @yanderezaf 10 หลายเดือนก่อน +1

    thank you so much for this tuto and the easy explanation.

  • @itsPatticatti
    @itsPatticatti ปีที่แล้ว +6

    IMPORTANT: if your tooltip is flickering, turn off "Raycast Target" under "Image" of your Tooltip parent. Don't need to change the pivot at all.

    • @pedropc5824
      @pedropc5824 10 หลายเดือนก่อน +1

      Thanks!

    • @atnguyenhuu2730
      @atnguyenhuu2730 6 หลายเดือนก่อน +1

      I fixed my problem Thank u so much!!!

  • @lightningcode1136
    @lightningcode1136 3 ปีที่แล้ว +3

    I may have to use this someday..

  • @Diertstarr
    @Diertstarr 2 ปีที่แล้ว +4

    I just spend hours trying to figure this out: the coin is a gameObject - NOT A UI ELEMENT. So I got that to work, but having trouble with figuring out how to tool tip the UI.
    Thank anyhow.

  • @cataend
    @cataend 3 ปีที่แล้ว +1

    Amazing tutorial

  • @eileeng2492
    @eileeng2492 3 ปีที่แล้ว +2

    Hey this seems doable.
    Gonna try it

  • @revmatch6r
    @revmatch6r 3 ปีที่แล้ว +1

    Finally a way to label all my spikey bois

  • @amandacollins7392
    @amandacollins7392 3 ปีที่แล้ว

    BMO, impressive Tooltip box 😏

  • @康凯-s9v
    @康凯-s9v 7 หลายเดือนก่อน

    Thank you for your tutorial. And I have a question. As I known transform.position is world space position, Input.mousePosition is screen space position. Why transform.position = mousePosition can work well? thanks again.

  • @FazzoHD
    @FazzoHD 3 ปีที่แล้ว +4

    How would you make this work for button objects as well?

    • @JessicaUresti01
      @JessicaUresti01 2 ปีที่แล้ว +1

      Yes I need this.

    • @ooOSp4wNOoo
      @ooOSp4wNOoo 2 ปีที่แล้ว

      Just add a boxCollider and a rigidbody... Dont forget to resize the BoxCollider

  • @k1rzen
    @k1rzen 7 หลายเดือนก่อน

    thank you so much

  • @tanawatmunmueang7924
    @tanawatmunmueang7924 8 หลายเดือนก่อน

    Thank you

  • @kedrickkarasek6736
    @kedrickkarasek6736 ปีที่แล้ว +2

    I tried clicking and dragging the pivot to the corner and it doesnt grab

    • @futurist1399
      @futurist1399 ปีที่แล้ว +4

      on the top left of your scene window change Center to Pivot

  • @Mikes-Code
    @Mikes-Code ปีที่แล้ว

    Thanks.

  •  5 หลายเดือนก่อน

    how can you just drag the pivot away? i cant seem to do that

  • @LoganGarnham
    @LoganGarnham ปีที่แล้ว +1

    would this work in a 3D game?

  • @MythicBeanProductions
    @MythicBeanProductions ปีที่แล้ว

    Any idea how to do this with visual scripting? I'm fairly new to this and have a hard time understanding the normal syntax layout of C#. I kind of know how to translate over but it's still pretty difficult and I can't figure this out

  • @hawkfish88
    @hawkfish88 2 ปีที่แล้ว

    I didn't need a rigidbody component for this to work.

  • @makeytgreatagain6256
    @makeytgreatagain6256 2 ปีที่แล้ว +1

    How do i stop the stuttering on the tooltip?

    • @Slort_
      @Slort_ ปีที่แล้ว +4

      For anyone having this problem: Just move the pivot point (the blue circle) of the panel a little outside the box.

    • @theepicraccoon4589
      @theepicraccoon4589 ปีที่แล้ว

      @@Slort_ thank you

    • @Imperial_Dynamics
      @Imperial_Dynamics ปีที่แล้ว +1

      The shuttering is caused when the mouse pointer is above the tooltipbox. I solved it by setting my pivot to: -0.1, -0.3

    • @itsPatticatti
      @itsPatticatti ปีที่แล้ว

      For anyone having this problem, turn off raycast target under image in your tooltip parent 100% works, changing the pivot point is just brute forcing it and wont change the fact that ur tooltip parent will still trigger the event.

  • @tofaani
    @tofaani 2 ปีที่แล้ว

    👍💎💎💎

  • @markn327
    @markn327 3 ปีที่แล้ว +3

    this didnt work for me.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using TMPro;
    public class toolTipManager : MonoBehaviour
    {
    public static toolTipManager _instance;
    public TextMeshProUGUI textComponent;
    private void Awake()
    {
    if (_instance != null && _instance != this)
    {
    Destroy(this.gameObject);
    }
    else
    {
    _instance = this;
    }
    }
    void Start()
    {
    Cursor.visible = true;
    gameObject.SetActive(false);
    }
    void Update()
    {
    transform.position = Input.mousePosition;
    }
    public void SetAndShowToolTip(string message)
    {
    gameObject.SetActive(true);
    textComponent.text = message;
    }
    public void HideToolTip()
    {
    gameObject.SetActive(false);
    textComponent.text = string.Empty;
    }
    }
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class toolTip : MonoBehaviour
    {
    public string message;
    private void OnMouseEnter()
    {
    toolTipManager._instance.SetAndShowToolTip(message);
    }
    private void OnMouseExit()
    {
    toolTipManager._instance.HideToolTip();
    }
    }

    • @markn327
      @markn327 3 ปีที่แล้ว +5

      ok so i figured out why this isnt working for me. The problem is that im looking to make a tool tip for a button on my ui canvas and not a tool tip for a game object in the world position. any thoughts on how to do that?

    • @alliion_x
      @alliion_x 2 ปีที่แล้ว

      @@markn327 hi, did you resolve this problem?

    • @galerez4194
      @galerez4194 2 ปีที่แล้ว +2

      @@alliion_x Hi, you can use IPointerEnter & IPointerExit interfaces (need to add using UnityEngine.EventSystems)

    • @Imperial_Dynamics
      @Imperial_Dynamics ปีที่แล้ว +4

      @@markn327 public class Tooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
      {
      public string message;
      public void OnPointerEnter(PointerEventData pointerEventData)
      {
      TooltipManager.instance.SetAndShowTooltip(message);
      }
      public void OnPointerExit(PointerEventData pointerEventData)
      {
      TooltipManager.instance.HideTooltip();
      }
      }