using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using DG.Tweening; using System.Threading.Tasks; public class SceneGuodu : MonoBehaviour { 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().isTransitioning = true; } } public async void SlideInAndLoadScene(string sceneName) { this.sceneName = sceneName; mask.transform.GetComponent().isTransitioning = false; await Task.Delay(1000); SceneManager.LoadScene(sceneName); } }