using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class OnlyTextPromptWin : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } /// /// 设置纯文本提示窗 /// /// 提示内容 /// 提示窗停留时间 public void SetWindow(string promptContent, float stayTime) { transform.SetParent(GameObject.Find("Canvas").transform, false); GetComponent().anchoredPosition = new Vector2(0, -155); transform.Find("Text").GetComponent().text = promptContent; StartCoroutine(DestoryWindow(stayTime)); transform.SetSiblingIndex(transform.parent.childCount - 2); } private IEnumerator DestoryWindow(float stayTime) { yield return new WaitForSeconds(stayTime); Destroy(gameObject); } }