关卡完成后,将显示获胜屏幕。其中有两个按钮继续和菜单。我已经设法停用按钮,只保持第一级按钮解锁,但当我清除 1 级时无法解锁 2 级按钮。我也希望继续按钮在它之后跳转到 2 级在完成关卡 1 时显示在下一个场景中。这个游戏是突围风格,这些是我无法解决的问题。我附上了我认为必要的相应脚本。如果你想要其他人请在评论中询问他们。所有脚本的完整列表在最后。我真的很感激一些帮助。如果你要求他们,我一定会尝试更多地解释我的问题。所以请稍后再检查这个问题以检查更改。
下面的脚本附加到第 1 级:-
{
[SerializeField] int breakableBlocks; // Serialized for debugging purposes
SceneLoader sceneloader;
private void Start()
{
sceneloader = FindObjectOfType<SceneLoader>();
}
public void CountBreakableBlocks()
{
breakableBlocks++;
}
public void BlockDestroyed()
{
breakableBlocks--;
if (breakableBlocks <= 0)
{
GetComponent<LevelSelector>().levelunlocked =
sceneloader.LoadWinScreen();
}
}
}
下面的脚本附加到级别选择器:-
{
public Button[] levelButtons;
public int levelunlocked = 1;
private void Start()
{
int levelReached = PlayerPrefs.GetInt("levelReached", levelunlocked);
for (int i = 0; i < levelButtons.Length; i++)
{
if (i + 1 > levelReached)
{
levelButtons[i].interactable = false;
}
}
}
}
莫回无
相关分类