YanCheng_Metrology/Assets/Scripts/Project/UI/UI_Panel/UI_MaskPanel.cs

63 lines
1.3 KiB
C#

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<Image>("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;
}
}
/// <summary>
/// 显示
/// </summary>
public override void ShowMe()
{
}
/// <summary>
/// 隐藏面板
/// </summary>
public override void HideMe()
{
}
}