| 12345678910111213141516171819202122232425262728293031 | using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.EventSystems;using UnityEngine.UI;public class TipShower : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler{    public RectTransform tips;    public string data;    public void OnPointerEnter(PointerEventData eventData)    {        currentShower = this;       // tips.anchoredPosition = this.GetComponent<RectTransform>().anchoredPosition;        tips.gameObject.SetActive(true);        tips.GetComponentInChildren<Text>().text = data;        //LayoutRebuilder.ForceRebuildLayoutImmediate(tips.GetChild(0).GetComponent<RectTransform>()); ; // 强制重新计算布局        //LayoutRebuilder.ForceRebuildLayoutImmediate(tips.GetComponent<RectTransform>()); // 强制重新计算布局    }    public static TipShower currentShower = null;    public void OnPointerExit(PointerEventData eventData)    {        if (currentShower == this) {            tips.gameObject.SetActive(false);            currentShower = null;        }    }   }
 |