Files
2024-10-29 17:16:17 +01:00

42 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
//this script stores the input name to the playerprefs
public class NameInputKeyboard : MonoBehaviour
{
[SerializeField] private Button enterButton;
[SerializeField] private TMP_Text inputText;
[SerializeField] private GameObject keyboardObject;
[SerializeField] private GameObject colorInput;
private void Start()
{
enterButton.onClick.AddListener( () =>
{
SetName(inputText.text);
keyboardObject.SetActive(false);
changeScene();
});
}
public void SetName(string name)
{
PlayerPrefs.SetString("playerName", name);
PlayerPrefs.Save();
}
public void changeScene()
{
//if the color has already been select, change the scene
if (colorInput.activeInHierarchy == false)
{
SceneManager.LoadScene("RoomCreation");
}
}
}