0
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{
    bool gameHasEnded = false;

    public float restartDelay = 1f;

            public void EndGame()
    {
            if (gameHasEnded == false)
            {
                gameHasEnded = true;
                Debug.Log("GAME OVER!");
                Invoke(nameof(Restart), restartDelay);
            }
            

        static void Restart()
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }
}

当玩家击中立方体时,我试图延迟“重启”。我不知道问题是否与“调用”方法有关。当我统一按下播放时,在控制台中它说 Trying to Invoke method: GameManager.Restart couldn't be called.

4

0 回答 0