1
我做的是使用Unity 4的教程和他們使用這樣的:如何在Unity 5中使用場景管理器移動到下一個場景?
Applicaiton.LoadLevel(Appliaction.loadedLevel +1);
,以移動到下一個場景。我正在使用unity 5,並且它告訴我使用場景管理器,因爲之前的方法現在已經過時。
什麼是替代上面的新代碼?
我做的是使用Unity 4的教程和他們使用這樣的:如何在Unity 5中使用場景管理器移動到下一個場景?
Applicaiton.LoadLevel(Appliaction.loadedLevel +1);
,以移動到下一個場景。我正在使用unity 5,並且它告訴我使用場景管理器,因爲之前的方法現在已經過時。
什麼是替代上面的新代碼?
Scene
struct有一個buildIndex
變量來存儲索引。因此,加載下一個場景:
using UnityEngine.SceneManagement;
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
if(currentSceneIndex<SceneManager.sceneCount-1)
{
SceneManager.LoadScene(currentSceneIndex + 1);
}
太棒了。這工作。非常感謝 – Ddrossi93