C# 如何使用Unity跳过一个级别';谁是运动员?

C# 如何使用Unity跳过一个级别';谁是运动员?,c#,android,unity3d,C#,Android,Unity3d,各位 我已经做了一段时间了。基本上,我正在开发一款手机游戏,我想设置我的广告按钮,以便在有人按下时跳过一个关卡。现在,它跟踪我离开的地方,但当我按下“重新启动”按钮并跳过尝试重新启动之前刚刚离开的级别时,它不会重置 我尝试使用两个不同的函数来处理这个问题,但首先,这里是重点和问题,int“sceneNo”和StartOver函数。我用PlayerRefs设置sceneNo。起来 sceneNo = PlayerPrefs.GetInt("Level", SceneManager.GetActiv

各位

我已经做了一段时间了。基本上,我正在开发一款手机游戏,我想设置我的广告按钮,以便在有人按下时跳过一个关卡。现在,它跟踪我离开的地方,但当我按下“重新启动”按钮并跳过尝试重新启动之前刚刚离开的级别时,它不会重置

我尝试使用两个不同的函数来处理这个问题,但首先,这里是重点和问题,int“sceneNo”和StartOver函数。我用PlayerRefs设置sceneNo。起来

sceneNo = PlayerPrefs.GetInt("Level", SceneManager.GetActiveScene().buildIndex);
这是StartOver的代码

public void StartOver()
{
    SceneManager.LoadScene(1);
    PlayerPrefs.DeleteKey("level");
    sceneNo = (SceneManager.GetActiveScene().buildIndex);
}
至于两个不同的功能,我已经尝试重置游戏

public void SkipMe()
{

    sceneNo = SceneManager.GetActiveScene().buildIndex + 1;
    SceneManager.LoadScene(PlayerPrefs.GetInt("Level", sceneNo));
}
现在的那个

public void SkipAdFunction()
{
    SceneManager.LoadScene(sceneNo);
    Answer.text = "";
    PlayerPrefs.SetInt("Level", sceneNo + 1);
    sceneNo = (SceneManager.GetActiveScene().buildIndex);

}
最后,下面是脚本的其余部分

void HandleShowResult(ShowResult result) { if (result == ShowResult.Finished) { Playable.GetComponent<LoadScene>().SkipMe();
void HandleShowResult(ShowResult结果){if(result==ShowResult.Finished){Playable.GetComponent().SkipMe();
这两个脚本做相同的事情。 对于如何解决此问题,我们将不胜感激。请提前感谢。

StartOver()中,您提到了这一点

 PlayerPrefs.DeleteKey("level");
但是在SkipMe()中,SkipAdFunction()是您编写的

PlayerPrefs.SetInt("Level", sceneNo + 1);

查看级别,您提到了不同的键,键区分大小写,因此更改它

1)您可以编辑您的问题,2)不要使用PlayerRefs。哦,天哪。我不敢相信我错过了。谢谢。不过,现在脚本跳过了两个级别。没问题……编码愉快