using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class xuanting2 : MonoBehaviour
{
// Start is called before the first frame update
bool isShowTip;
void Start()
{
isShowTip=false;
}
void OnMouseEnter(){
isShowTip=true;
}
void OnMouseExit(){
isShowTip=false;
}
void OnGUI(){
if(isShowTip){
GUIStyle style=new GUIStyle();
style.fontSize=50;
style.normal.textColor=Color.blue;
GUI.Label(new Rect(Input.mousePosition.x,Screen.height-Input.mousePosition.y,100,100),"2号风机" ,style);
}
}
}
添加悬停目标,显示出相应文字
这篇博客介绍了如何使用Unity3D为游戏场景中的2号风机添加鼠标悬停提示功能,通过OnMouseEnter和OnMouseExit事件,配合GUI.Label在鼠标进入和离开时动态显示文字。
4131

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



