asset integration 50%
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
public class LevelLoadManager : MonoBehaviour
|
||||
{
|
||||
public static LevelLoadManager instance;
|
||||
|
||||
public Image contentImage;
|
||||
public float transitionDuration = 0.5f;
|
||||
CanvasGroup canvasGroup;
|
||||
|
||||
public bool isShowing => canvasGroup.alpha == 1;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if(instance != null){
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
instance = this;
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
public static void LoadLevel(string levelName){
|
||||
instance.loadLevel(levelName);
|
||||
}
|
||||
|
||||
void loadLevel(string levelName){
|
||||
StartCoroutine(CoroutineLoadLevel(levelName));
|
||||
}
|
||||
|
||||
IEnumerator CoroutineLoadLevel(string levelName){
|
||||
instance.Show();
|
||||
yield return new WaitForSeconds(transitionDuration);
|
||||
yield return SceneManager.LoadSceneAsync(levelName);
|
||||
instance.Hide();
|
||||
}
|
||||
|
||||
|
||||
public void Show(){
|
||||
canvasGroup.blocksRaycasts=true;
|
||||
canvasGroup.interactable=true;
|
||||
contentImage.fillOrigin = 0;
|
||||
canvasGroup.DOFade(1, transitionDuration).SetEase(Ease.OutSine);
|
||||
contentImage.DOFillAmount(1, transitionDuration).SetEase(Ease.OutSine);
|
||||
}
|
||||
|
||||
public void Hide(){
|
||||
canvasGroup.blocksRaycasts=false;
|
||||
canvasGroup.interactable=false;
|
||||
contentImage.fillOrigin = 1;
|
||||
canvasGroup.DOFade(0, transitionDuration).SetEase(Ease.InSine);
|
||||
contentImage.DOFillAmount(0, transitionDuration).SetEase(Ease.InSine);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user