Better null check bug fix

Hey all… Instead of or in addition to the return for new game if the new game name is null, we should just check it in the Main Menu UI…

    public void NewGame()
    {
        if (!String.IsNullOrEmpty(newGameNameField.text))
        {
            GetComponent<CanvasGroup>().alpha = 0;
            savingWrapper.value.NewGame(newGameNameField.text);
        }
    }

I also added a Canvas Group to the main panel that sets transparency to 0 when you do a new game or continue game… It just looks nicer for that menu to disappear and show the whole menu scene during the fade. I also have it set to 1 in Awake just in case later we return to that menu so I don’t forget :joy:

What I did was this in MainMenuUI:

public void StartNewGame()
        {
            string saveFile;
            if(newGameNameField.text == "")
            {
                saveFile = "defaultSave";
            }
            else
            {
                saveFile = newGameNameField.text;
            }
            savingWrapper.value.NewGame(saveFile);
        }

Though it will overwrite any older save with the same name. I’m not far enough in the course to see how we deal with selecting different save files yet.

Privacy & Terms