在Hierarchy视图,新建UICanvas,鼠标悬浮在UICanvas物体上,鼠标右键-UI-Image,新建一个UGUIImage物体,挂载Test_Toolstip.cs脚本
Test_Toolstip.cs脚本
.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;//IPointerEnterHandler, IPointerExitHandler
public class Test_Toolstip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public void OnPointerEnter(PointerEventData eventData)
{
Debug.Log("Hello");
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("Bye");
}
}
运行并测试,鼠标移动至UI上面,便反馈一个Hello,离开则Bye
接着完善Tooltip提示框的UI即可。
相关文章:
1.

本文介绍了如何在Unity中使用UGUI创建Tooltip提示框,通过挂载Test_Toolstip.cs脚本来实现鼠标悬停显示反馈信息的功能。同时提到了Tooltip的UI完善以及相关文章,包括解决Tooltip闪烁问题、获取鼠标屏幕坐标、Tooltip文本自适应等。

2695

被折叠的 条评论
为什么被折叠?



