You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
4 years ago
|
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 () {
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置纯文本提示窗
|
||
|
/// </summary>
|
||
|
/// <param name="promptContent">提示内容</param>
|
||
|
/// <param name="stayTime">提示窗停留时间</param>
|
||
|
public void SetWindow(string promptContent, float stayTime)
|
||
|
{
|
||
|
transform.SetParent(GameObject.Find("Canvas").transform, false);
|
||
|
|
||
|
GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -155);
|
||
|
transform.Find("Text").GetComponent<Text>().text = promptContent;
|
||
|
StartCoroutine(DestoryWindow(stayTime));
|
||
|
transform.SetSiblingIndex(transform.parent.childCount - 2);
|
||
|
}
|
||
|
|
||
|
private IEnumerator DestoryWindow(float stayTime)
|
||
|
{
|
||
|
yield return new WaitForSeconds(stayTime);
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|