Unity scene jump method

  1. scene jump code
using UnityEngine.SceneManagement;	//引用命名空间

SceneManager.LoadScene("mainScene");//引号内为要跳转的场景名
SceneManager.LoadScene(0);	//也可以是导入Bulid的场景序列



Asynchronous scene jump

    private Action prgCB = null;
    
 	private void Update()
    {
    
    
        prgCB?.Invoke();
    }

    public void LoadSceneAsync(string sceneName)
    {
    
    
        AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(sceneName);
        prgCB = () =>
        {
    
    
            float val = asyncOperation.progress;
            if (val == 1)
            {
    
    
                asyncOperation = null;
                prgCB = null;
            }
        };
    }

Guess you like

Origin blog.csdn.net/ashmoc/article/details/108200975