using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class ChangeUserScreen : MonoBehaviour { /// /// Prefab of the user selection /// public GameObject userPrefab; /// /// Reference to the container to list all users /// public Transform usersContainer; /// /// Reference to the user list /// public UserList userList; /// /// Index of the current selected user in the UserList /// private int currentUserIndex; /// /// List of references to avatar background sprites (so we can color them nicely) /// private List userBackgrounds = new List(); /// /// Start is called before the first frame update /// void Start() { List users = userList.GetUsers(); currentUserIndex = userList.GetCurrentUserIndex(); for (int i = 0; i < users.Count; i++) { User user = users[i]; // Create instance of prefab GameObject instance = GameObject.Instantiate(userPrefab, usersContainer); // 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