Skip to content
Snippets Groups Projects
Commit fcc144c0 authored by Jesica's avatar Jesica
Browse files

fix name input

parent 5cbf9faa
No related merge requests found
...@@ -13,6 +13,7 @@ public class MainMenu : MonoBehaviour ...@@ -13,6 +13,7 @@ public class MainMenu : MonoBehaviour
public void QuitGame() public void QuitGame()
{ {
Debug.Log("QUIT!"); Debug.Log("QUIT!");
PlayerPrefs.DeleteAll(); // TODO harus disimpen ga ya?
Application.Quit(); Application.Quit();
} }
} }
...@@ -23,11 +23,31 @@ public class NameInput : MonoBehaviour ...@@ -23,11 +23,31 @@ public class NameInput : MonoBehaviour
labelText.GetComponent<TextMeshProUGUI>().text = "Name cannot be empty!"; labelText.GetComponent<TextMeshProUGUI>().text = "Name cannot be empty!";
} else } else
{ {
textDisplay.GetComponent<TextMeshProUGUI>().text = "Welcome " + theName + "!";
PlayerPrefs.SetString("name", theName);
PlayerPrefs.Save();
// direct ke main menu // direct ke main menu
mainMenu.SetActive(true); mainMenu.SetActive(true);
nameInput.SetActive(false); nameInput.SetActive(false);
}
}
textDisplay.GetComponent<TextMeshProUGUI>().text = "Welcome " + theName + "!"; private void Start()
{
Debug.Log("Start in NameInput is called");
theName = PlayerPrefs.GetString("name");
if (string.IsNullOrEmpty(theName) || string.IsNullOrWhiteSpace(theName))
{
nameInput.SetActive(true);
mainMenu.SetActive(false);
} else
{
mainMenu.SetActive(true);
nameInput.SetActive(false);
textDisplay.GetComponent<TextMeshProUGUI>().text = "Hi " + theName + "!";
} }
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment