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.
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.
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.
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
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.
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.
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
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.
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?
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.
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.
Damn dude loving the flow of videos coming out, great work
Extremely useful, easy to follow, and easy to modify for any project. Thanks for this!
This is excellent! So many uses, and gives the game a way to interact with the player. Thank you.
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.
YOU ARE THE GOAT
Thanks!!!!
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
@@itsPatticatti Thanks for that. 🇮🇳☺️😇
thank you so much for this tuto and the easy explanation.
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.
Thanks!
I fixed my problem Thank u so much!!!
I may have to use this someday..
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.
Amazing tutorial
Hey this seems doable.
Gonna try it
Finally a way to label all my spikey bois
BMO, impressive Tooltip box 😏
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.
How would you make this work for button objects as well?
Yes I need this.
Just add a boxCollider and a rigidbody... Dont forget to resize the BoxCollider
thank you so much
Thank you
I tried clicking and dragging the pivot to the corner and it doesnt grab
on the top left of your scene window change Center to Pivot
Thanks.
how can you just drag the pivot away? i cant seem to do that
would this work in a 3D game?
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
I didn't need a rigidbody component for this to work.
How do i stop the stuttering on the tooltip?
For anyone having this problem: Just move the pivot point (the blue circle) of the panel a little outside the box.
@@Slort_ thank you
The shuttering is caused when the mouse pointer is above the tooltipbox. I solved it by setting my pivot to: -0.1, -0.3
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.
👍💎💎💎
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();
}
}
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?
@@markn327 hi, did you resolve this problem?
@@alliion_x Hi, you can use IPointerEnter & IPointerExit interfaces (need to add using UnityEngine.EventSystems)
@@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();
}
}