Cute_demon_attacks/meng_yao/Assets/script/JumpScene/SceneGuodu.cs
2024-11-08 00:41:10 +08:00

52 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using DG.Tweening;
using System.Threading.Tasks;
public class SceneGuodu : MonoBehaviour
{
public bool is_lock = false;
public static SceneGuodu instance;
public string sceneName;
public float transitionTime = 1f; // 过渡时间
public GameObject mask;//遮罩
private void Start()
{
if (instance == null)
{
DontDestroyOnLoad(this);
instance = this;
}
SceneManager.sceneLoaded += loadEnd;
}
void loadEnd(Scene scene, LoadSceneMode mode)
{
Debug.Log("场景加载完成:" + scene.name);
if (mask != null )
{
mask.transform.GetComponent<CircleDissolveEffect>().isTransitioning = true;
}
is_lock = false;
}
public async void SlideInAndLoadScene(string sceneName)
{
if (!is_lock)
{
is_lock = true;
this.sceneName = sceneName;
mask.transform.GetComponent<CircleDissolveEffect>().isTransitioning = false;
await Task.Delay(1000);
SceneManager.LoadScene(sceneName);
}
}
}