40 lines
895 B
C#
40 lines
895 B
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class LoadingUI : MyCoroutine
|
||
|
|
{
|
||
|
|
public static LoadingUI Ins;
|
||
|
|
public GameObject go;
|
||
|
|
public Image sprite_bg;
|
||
|
|
|
||
|
|
void Awake()
|
||
|
|
{
|
||
|
|
Ins = this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Set(bool _active, Action _act = null)
|
||
|
|
{
|
||
|
|
if (_active)
|
||
|
|
{
|
||
|
|
sprite_bg.canvasRenderer.SetAlpha(1f);
|
||
|
|
go.SetActive(_active);
|
||
|
|
Set_Coroutine(_act, 0.5f);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
StartCoroutine(Co_Alpha());
|
||
|
|
}
|
||
|
|
|
||
|
|
IEnumerator Co_Alpha()
|
||
|
|
{
|
||
|
|
while (sprite_bg.canvasRenderer.GetAlpha() > 0f)
|
||
|
|
{
|
||
|
|
var alpha = sprite_bg.canvasRenderer.GetAlpha();
|
||
|
|
sprite_bg.canvasRenderer.SetAlpha(alpha - Time.deltaTime * 0.5f);
|
||
|
|
yield return null;
|
||
|
|
}
|
||
|
|
go.SetActive(false);
|
||
|
|
}
|
||
|
|
}
|