How to Make A Simple Tooltip in Unity Tutorial

How to Make A Simple Tooltip in Unity Tutorial

BMo

3 года назад

19,909 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@itsPatticatti
@itsPatticatti - 12.09.2023 08:20

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.

Ответить
@IndicIndieGameDev
@IndicIndieGameDev - 28.08.2023 14:58

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.

Ответить
@user-mb4go4ng8b
@user-mb4go4ng8b - 26.06.2023 12:22

would this work in a 3D game?

Ответить
@kedrickkarasek6736
@kedrickkarasek6736 - 24.06.2023 05:52

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

Ответить
@lalitsharma3137
@lalitsharma3137 - 17.06.2023 13:27

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.

Ответить
@helciowagner6101
@helciowagner6101 - 31.03.2023 23:48

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.

Ответить
@ibelonghere
@ibelonghere - 17.03.2023 20:21

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

Ответить
@MythicBeanProductions
@MythicBeanProductions - 16.03.2023 00:56

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

Ответить
@Mikes-Code
@Mikes-Code - 24.01.2023 15:25

Thanks.

Ответить
@Diertstarr
@Diertstarr - 10.12.2022 08:01

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.

Ответить
@danieller213
@danieller213 - 11.10.2022 00:08

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

Ответить
@c3i
@c3i - 02.10.2022 04:38

👍💎💎💎

Ответить
@makeytgreatagain6256
@makeytgreatagain6256 - 18.08.2022 06:33

How do i stop the stuttering on the tooltip?

Ответить
@hawkfish88
@hawkfish88 - 09.07.2022 12:36

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

Ответить
@bakihanma1680
@bakihanma1680 - 14.01.2022 00:01

what a fucking joke, who would want a tool tip that can't interact the UI elements.

Ответить
@FazzoHD
@FazzoHD - 15.11.2021 00:07

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

Ответить
@markn327
@markn327 - 04.10.2021 20:39

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();
}
}

Ответить
@cataend
@cataend - 05.08.2021 21:52

Amazing tutorial

Ответить
@amandacollins7392
@amandacollins7392 - 26.04.2021 01:35

BMO, impressive Tooltip box 😏

Ответить
@revmatch6r
@revmatch6r - 23.04.2021 05:45

Finally a way to label all my spikey bois

Ответить
@eileeng2492
@eileeng2492 - 22.04.2021 23:16

Hey this seems doable.
Gonna try it

Ответить
@deadbroadcastpc
@deadbroadcastpc - 22.04.2021 19:10

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

Ответить
@lightningcode1136
@lightningcode1136 - 22.04.2021 17:19

I may have to use this someday..

Ответить