如图,一个Cube,和它的标签“中国立方体”——目的是鼠标移到标签上,显示标签;鼠标移出,隐藏标签:脚本中用到的相应的系统函数OnMouseOver/OnMouseExit
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestMouseHoverExit : MonoBehaviour
{
public GameObject labelOfCube;
private void OnMouseOver()
{
labelOfCube.SetActive(true);
}
private void OnMouseExit()
{
labelOfCube.SetActive(false);
}
}