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.
36 lines
1.2 KiB
36 lines
1.2 KiB
using System.Collections; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class TextHintWindowManager : MonoBehaviour |
|
{ |
|
/// <summary> |
|
/// 文本提示 |
|
/// </summary> |
|
/// <param name="hintText">提示内容</param> |
|
/// <param name="stayTime">停留时间</param> |
|
public void SetWindow(string hintText, float stayTime) |
|
{ |
|
transform.name = "HintTextWindow"; |
|
//transform.SetParent(GameObject.Find("Canvas").transform); |
|
//if (transform.parent.GetComponent<CanvasScaler>().referenceResolution.x != 1920) |
|
//{ |
|
// transform.localScale = new Vector3(0.8f, 0.8f, 1); |
|
//} |
|
//else |
|
//{ |
|
// transform.localScale = new Vector3(1, 1, 1); |
|
//} |
|
//GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 300); |
|
transform.Find("Text").GetComponent<Text>().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); |
|
} |
|
}
|
|
|