1.提示框UI组件:
UI资源:
字体资源:
2.代码脚本:ToastPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class ToastPanel : BasePanel
{
static string showText;
public Text text;
public static void Show(string showText) {
ToastPanel.showText = showText;
UIManager.Instance.PushPanel(UIPanelType.TOAST_PANEL);
}
public override void OnEnter() {
base.OnEnter();
text.text = showText;
StopAllCoroutines();
StartCoroutine(WaitHide());
}
IEnumerator WaitHide() {
yield return new WaitForSeconds(2f);
gameObject.SetActive(false);
}
}
3.提示框使用:
ToastPanel.Show("不是有效链接");
4.这个提示框使用的到UI管理器框架:
5.UI管理器框架脚本见其他文文章--Unity组件开发--UI管理器