コード例 #1
0
    void Awake()
    {
        //Singleton...ish...
        //put the GameManager prefab in all scenes and this will remove any we don't need
        if (gameManager == null)
        {
            DontDestroyOnLoad(gameObject);
            gameManager = this;
        }
        else if (gameManager != this)
        {
            Destroy(gameObject);
        }

        curScene = "01"; //deliberately wrong for debugging...
        //TODO: change curScene to firstScene when everything is working to ensure it can't crash the game if something goes wrong, it'll just enforce a full game restart instead which is less jarring

        //TODO the following are just to assist whilst building the game, should probably delete once game is finished:
        isFullRestart = false;
        hasShells     = true;

        //required for setting and updating speed of game as it goes along. SceneManager will call OnSceneLoaded() when the sceneLoaded event happens
        speed = 2;
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
コード例 #2
0
 void Start()
 {
     gameManager = GameMGMT.gameManager;
 }