using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class login : MonoBehaviour
{
    public InputField nameInput;
    public Button loginBtn;
    void Start()
    {
        loginBtn.interactable = false;
        if (PlayerPrefs.HasKey("username") && PlayerPrefs.GetString("username").Length > 3)
        {
            SceneManager.LoadScene("MainMenu");
            return;
        }

        nameInput.onValueChanged.AddListener(OnNameinputChange);
    }


    void OnNameinputChange(string value)
    {
        loginBtn.interactable = (value.Length > 3);
    }

    public void Login(){
        if(nameInput.text.Length <=3){return;}

        PlayerPrefs.SetString("username", nameInput.text);
        PlayerPrefs.Save();

        SceneManager.LoadScene("MainMenu");
    }
}
