using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

public class ScenesMgr : BaseMgr<ScenesMgr>
{
    public void LoadScene(int num,UnityAction callback=null)
    {
        SceneManager.LoadScene(num);
        callback?.Invoke();
    }

    public void LoadSceneAsync(int num, UnityAction<float> func = null,UnityAction callback=null) 
    {
        MonoMgr.Getinstance().StartCoroutine(InsideLoadSceneAsync(num, func,callback));
    }

    public IEnumerator InsideLoadSceneAsync(int num,UnityAction<float> func = null,UnityAction callback=null) 
    {
        AsyncOperation ao= SceneManager.LoadSceneAsync(num);

        while (!ao.isDone)
        {
            func?.Invoke((ao.progress/9)*10);
            yield return 0;
        }

        callback?.Invoke();
    }
}
