using System.Collections.Generic; using System.Text.RegularExpressions; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// UserCreationScreen scene manager /// public class UserCreationScreen : MonoBehaviour { /// /// Maximum lenght of a username /// private const int MAX_USERNAME_LENGTH = 12; /// /// Reference to the error message to display when a certain usernmae is invalid or already exists /// public GameObject errorMessage; /// /// Reference to the input text field for username /// public TMP_InputField inputName; /// /// Reference to the avatar-list container /// public Transform avatarsContainer; /// /// Avatar prefab /// public GameObject avatarPrefab; /// /// Current selected avatar /// private int selectedAvatar = 0; /// /// List of references to avatar background sprites (so we can color them nicely) /// private List avatars = new List(); /// /// Reference to the back button, so we can deactivate it when the user cannot go back (when no user is found at startup) /// public GameObject backButton; /// /// Boolean used to check whether the user can go back to the previous scene /// public static bool canGoBack = true; /// /// Start is called before the first frame update /// void Start() { errorMessage.SetActive(false); backButton.SetActive(canGoBack); // Reset to default value UserCreationScreen.canGoBack = true; for (int i = 0; i < UserList.AVATARS.Count; i++) { // Create instance of prefab GameObject instance = GameObject.Instantiate(avatarPrefab, avatarsContainer); // Store value of i so we can use it the callback (else it would get the value of sprites.Count) int x = i; // Add onClick callback instance.GetComponent