using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; [AddComponentMenu("UISuspensionDeveloper/悬浮UI")] public class UISuspensionDeveloper : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { public GameObject game; public Text text1; public Text text2; public bool isexceed = false; public void OnPointerEnter(PointerEventData eventData) { Debug.Log("preferredWidth:" + text1.preferredWidth); Debug.Log("preferredHeight:" + text1.preferredHeight); if (text1.preferredWidth > text1.rectTransform.rect.width || text1.preferredHeight > text1.rectTransform.rect.height) { if (isexceed) game.transform.SetParent(PatternChoose.Inst.transform); game.SetActive(true); text2.gameObject.SetActive(true); text2.text = text1.text; } } public void OnPointerExit(PointerEventData eventData) { if (isexceed) game.transform.SetParent(this.transform); game.SetActive(false); } void Awake() { } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } }