我正在用c#统一制作游戏,我希望如果您在第4级中死亡,您会回到第0级,但是如果您在第5级中,那么您会在第5级重生 编码:
{
int currentSceenIndex = SceneManager.GetActiveScene().buildIndex;
if (currentSceenIndex <= 4)
{
SceneManager.LoadScene(0);
}
else if (currentSceenIndex == 4)
{
SceneManager.LoadScene(4);
}
}
我做错了什么,重生仍然有效,但我总是回到0级如何解决此问题
听起来您想使用
instead of
<=
since currently the second block would never be reached since forcurrentSceenIndex == 4
it already executes theif
block