using System.Collections; using UnityEngine; using UnityEngine.UI; public class TextHintWindowManager : MonoBehaviour { /// /// 文本提示 /// /// 提示内容 /// 停留时间 public void SetWindow(string hintText, float stayTime) { transform.name = "HintTextWindow"; //transform.SetParent(GameObject.Find("Canvas").transform); //if (transform.parent.GetComponent().referenceResolution.x != 1920) //{ // transform.localScale = new Vector3(0.8f, 0.8f, 1); //} //else //{ // transform.localScale = new Vector3(1, 1, 1); //} //GetComponent().anchoredPosition = new Vector2(0, 300); transform.Find("Text").GetComponent().text = hintText; StartCoroutine(DestoryWindow(stayTime)); //transform.SetSiblingIndex(transform.parent.childCount - 2); transform.SetAsLastSibling(); } private IEnumerator DestoryWindow(float stayTime) { yield return new WaitForSeconds(stayTime); Destroy(gameObject); } }