Resolve WES-117 "Persistent data handling"
This commit is contained in:
@@ -34,20 +34,9 @@ public class UserCreationScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public GameObject avatarPrefab;
|
||||
|
||||
/// <summary>
|
||||
/// List of all sprites that are supported as avatars
|
||||
/// </summary>
|
||||
public List<Sprite> sprites = new List<Sprite>();
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the UserList ScriptableObject
|
||||
/// </summary>
|
||||
public UserList users;
|
||||
|
||||
/// <summary>
|
||||
/// Current selected avatar
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private int selectedAvatar = 0;
|
||||
|
||||
/// <summary>
|
||||
@@ -63,7 +52,7 @@ public class UserCreationScreen : MonoBehaviour
|
||||
{
|
||||
errorMessage.SetActive(false);
|
||||
|
||||
for (int i = 0; i < sprites.Count; i++)
|
||||
for (int i = 0; i < UserList.AVATARS.Count; i++)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(avatarPrefab, avatarsContainer);
|
||||
@@ -79,7 +68,7 @@ public class UserCreationScreen : MonoBehaviour
|
||||
// Set background color
|
||||
background.color = selectedAvatar == i ? Color.blue : Color.gray;
|
||||
// Find correct component for setting the sprite
|
||||
instance.transform.Find("Image").GetComponent<Image>().sprite = sprites[i];
|
||||
instance.transform.Find("Image").GetComponent<Image>().sprite = UserList.AVATARS[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,10 +102,10 @@ public class UserCreationScreen : MonoBehaviour
|
||||
string username = inputName.text;
|
||||
if (IsValidUsername(username))
|
||||
{
|
||||
if (users.GetUserByUsername(username) == null)
|
||||
if (UserList.GetUserByUsername(username) == null)
|
||||
{
|
||||
// Create a new entry in the UserList ScriptableObject
|
||||
users.ChangeCurrentUser(users.CreateAndAddNewUser(username, sprites[selectedAvatar]));
|
||||
UserList.AddUser(username, UserList.AVATARS[selectedAvatar]);
|
||||
SystemController.GetInstance().BackToPreviousScene();
|
||||
}
|
||||
// Warn user that username already exists
|
||||
|
||||
Reference in New Issue
Block a user