unity3D 重新加載當前場景&加載當前場景的下一個場景


加載前,請先Build場景

右側的數字就是場景的ID下標

 

加載場景方法:SceneManager.LoadScene()

如果要重新加載當前場景,請將+1刪除

加載場景(當前激活場景.建造下標+1)

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1)

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 using UnityEngine.SceneManagement;
 5 
 6 public class LoadScence : MonoBehaviour
 7 {
 8  
 9     void Update()
10     {
11 
12         if (Input.GetKeyDown(KeyCode.N))
13         {
14             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
15         }
16 
17     }
18 }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM