Dim*_*zyr 1 c# unity-game-engine
在我的游戏中,我的主菜单带有“新游戏”按钮。我需要检查,如果我在此游戏会话中第一次按下此按钮,例如:
我用这个按钮开始新游戏(第一次按),然后从游戏返回主菜单,然后再次按这个按钮(不是第一次按)。
public void ButtonNewGame()
{
if() // if the game was started once
{
GameObject gameMAnagerObj = GameObject.FindGameObjectWithTag("GameManager");
GameManager gameManagerScript = gameMAnagerObj.GetComponent<GameManager>();
gameManagerScript.currentActNumber = 0;
act_0.stepNumber = 0;
}
SceneManager.LoadScene("Casino");
}
Run Code Online (Sandbox Code Playgroud)
public static bool IsStartedFirstTime = false;
public void ButtonNewGame()
{
if(IsStartedFirstTime == false) // if the game was started once
{
IsStartedFirstTime = true;
//Logic on first time run
//return; //depending on your intent, you might wish to return or not!
}
if(IsStartedFirstTime)
// your logic that happens if it is already started
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
146 次 |
| 最近记录: |