using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using DuloGames.UI.Tweens;
namespace DuloGames.UI
{
///
/// Loading Overlay
/// This script requires to be attached to a canvas.
/// The canvas must have the highest sorting order.
/// The canvas must have a GraphicRaycaster.
/// The visibility of the overlay is controlled by a CanvasGroup alpha.
///
[RequireComponent(typeof(Canvas)), RequireComponent(typeof(GraphicRaycaster)), AddComponentMenu("UI/Loading Overlay", 58)]
public class UILoadingOverlay : MonoBehaviour
{
[SerializeField] private UIProgressBar m_ProgressBar;
[SerializeField] private CanvasGroup m_CanvasGroup;
[Header("Transition")]
[SerializeField] private TweenEasing m_TransitionEasing = TweenEasing.InOutQuint;
[SerializeField] private float m_TransitionDuration = 0.4f;
private bool m_Showing = false;
private int m_LoadSceneId = 0;
// Tween controls
[System.NonSerialized] private readonly TweenRunner m_FloatTweenRunner;
// Called by Unity prior to deserialization,
// should not be called by users
protected UILoadingOverlay()
{
if (this.m_FloatTweenRunner == null)
this.m_FloatTweenRunner = new TweenRunner();
this.m_FloatTweenRunner.Init(this);
}
protected void Awake()
{
DontDestroyOnLoad(this.gameObject);
// Make sure it's top most ordering number
Canvas[] canvases = FindObjectsOfType