using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UI_MaskPanel : BasePanel { private float fadeInSpeed = 0.5f; // 淡入速度 private float fadeOutSpeed = 0.5f; // 淡出速度 private float pauseTime = 3f; // 停留时间 public void Init() { } private void Start() { StartCoroutine(FadeInAndOut()); } IEnumerator FadeInAndOut() { Image image_Mask = GetControl("UI_MaskPanel"); // 淡入 float alpha = 0.0f; while (alpha < 1.0f) { alpha += fadeInSpeed * Time.deltaTime; image_Mask.color = new Color(0, 0, 0, alpha); yield return null; } // 停留 yield return new WaitForSeconds(pauseTime); // 淡出 alpha = 1.0f; while (alpha > 0.0f) { alpha -= fadeOutSpeed * Time.deltaTime; image_Mask.color = new Color(0, 0, 0, alpha); yield return null; } } /// /// 显示 /// public override void ShowMe() { } /// /// 隐藏面板 /// public override void HideMe() { } }