using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class Choose : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { public bool isNoTip; public bool isShow; public GameObject Tip; public void Start() { Transform childTransform = transform.Find("Choose_Bg/Choos_Tip"); Tip = childTransform.gameObject; } private void Update() { if (isShow&&isNoTip) { Tip.SetActive(true); } else { Tip.SetActive(false); } } // 当鼠标进入时 public void OnPointerEnter(PointerEventData eventData) { isShow = true;// 显示面板 } // 当鼠标离开时 public void OnPointerExit(PointerEventData eventData) { isShow = false; // 隐藏面板 } }