Wes xx build fix

This commit is contained in:
Dries Van Schuylenbergh
2023-03-09 12:44:11 +00:00
committed by Louis Adriaens
parent 601cf38c61
commit 2fa54620ef
74 changed files with 1009 additions and 214 deletions

View File

@@ -1,212 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6263784958278830195
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6263784958278830196}
- component: {fileID: 6263784958278830198}
- component: {fileID: 6263784958278830197}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6263784958278830196
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784958278830195}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6263784960026409965}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6263784958278830198
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784958278830195}
m_CullTransparentMesh: 1
--- !u!114 &6263784958278830197
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784958278830195}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &6263784960026409964
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6263784960026409965}
- component: {fileID: 6263784960026409952}
- component: {fileID: 6263784960026409967}
- component: {fileID: 6263784960026409966}
m_Layer: 5
m_Name: Avatar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6263784960026409965
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784960026409964}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6263784958278830196}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6263784960026409952
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784960026409964}
m_CullTransparentMesh: 1
--- !u!114 &6263784960026409967
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784960026409964}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &6263784960026409966
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6263784960026409964}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 6263784960026409967}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: c09ef5423059da444ad7743174e9f077
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -797,6 +797,7 @@ GameObject:
- component: {fileID: 906197777}
- component: {fileID: 906197779}
- component: {fileID: 906197778}
- component: {fileID: 906197780}
m_Layer: 5
m_Name: Panel
m_TagString: Untagged
@@ -867,6 +868,19 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 906197776}
m_CullTransparentMesh: 1
--- !u!114 &906197780
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 906197776}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e7cdd358c46e3f94398d91b7118e6d39, type: 3}
m_Name:
m_EditorClassIdentifier:
userList: {fileID: 11400000, guid: 072bec636a40f7e4e93b0ac624a3bda2, type: 2}
--- !u!1 &955994877
GameObject:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 401cfc17c01f88847b434260a6a93933
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,18 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3f3d6d68c3c3db64e91cf5ec9537ccda, type: 3}
m_Name: UserList
m_EditorClassIdentifier:
userTemplate: {fileID: 11400000, guid: 9195fb19688f1834fac39d356f965c20, type: 2}
users:
- {fileID: 11400000, guid: 5953482dbce359e4eb263eea279dd0c5, type: 2}
currentUserIndex: 0

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 072bec636a40f7e4e93b0ac624a3bda2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,19 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c6c5919d9f747143b377c2bc34cd28b, type: 3}
m_Name: UserTemplate
m_EditorClassIdentifier:
username:
avatar: {fileID: 21300000, guid: 0c9156aa9168241eaacc01c996d6aa97, type: 3}
playtime: 0
courses: []
minigames: []

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9195fb19688f1834fac39d356f965c20
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: dc83c2f6756fa3e43976e529562dd622
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c6c5919d9f747143b377c2bc34cd28b, type: 3}
m_Name: dvschuyl
m_EditorClassIdentifier:
username: dvschuyl
avatar: {fileID: 21300000, guid: 2098bf9fafbc5b31e89e5b7ad8f1f5e2, type: 3}
playtime: 0
courses:
- entries:
- key: courseIndex
bytes: 0001000000ffffffff01000000000000000c0200000046417373656d626c792d4353686172702c2056657273696f6e3d302e302e302e302c2043756c747572653d6e65757472616c2c205075626c69634b6579546f6b656e3d6e756c6c05010000000b436f75727365496e646578010000000776616c75655f5f000802000000000000000b
- key: courseProgress
bytes: 0001000000ffffffff010000000000000004010000000d53797374656d2e53696e676c6501000000076d5f76616c7565000b0000803e0b
minigames:
- entries:
- key: minigameIndex
bytes: 0001000000ffffffff01000000000000000c0200000046417373656d626c792d4353686172702c2056657273696f6e3d302e302e302e302c2043756c747572653d6e65757472616c2c205075626c69634b6579546f6b656e3d6e756c6c05010000000d4d696e6967616d65496e646578010000000776616c75655f5f000802000000000000000b
- key: highscore
bytes: 0001000000ffffffff010000000000000004010000000c53797374656d2e496e74333201000000076d5f76616c75650008000000000b

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 5953482dbce359e4eb263eea279dd0c5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

View File

@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

View File

@@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -26,7 +25,7 @@ public class CourseScreenManager : MonoBehaviour
void Start()
{
User user = userList.users[userList.currentUserIndex];
User user = userList.GetCurrentUser();
// Recent courses
List<Tuple<CourseIndex, float>> recentCourses = user.GetRecentCourses();

View File

@@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Create new Scriptable/Minigame")]

View File

@@ -1,6 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// TODO: add other courses
public enum MinigameIndex

View File

@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

View File

@@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

View File

@@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

View File

@@ -1,80 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
[Serializable]
// Can not be created from Editor
public class Progress
{
[Serializable]
// Helper class to serialize into byte[]
protected class DataEntry
{
public string key;
public List<byte> bytes = new List<byte>();
public DataEntry(string key, byte[] data)
{
this.key = key;
this.bytes = new List<byte>(data);
}
}
[Header("Course or Minigame")]
[SerializeField]
// values belonging to a certain key, in List (which can be serialized)
private List<DataEntry> entries = new List<DataEntry>();
// Add new `key` := `value`, returns `true` if successful
public bool AddOrUpdate<T>(string key, T data)
{
if (data == null)
return false;
DataEntry entry = entries.Find(x => x.key == key);
// Hacky serialization stuff
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
bf.Serialize(ms, data);
if (entry != null)
{
entry.bytes.Clear();
entry.bytes.AddRange(ms.ToArray());
}
else
{
entries.Add(new DataEntry(key, ms.ToArray()));
}
return true;
}
}
// Get the value of type `T` belonging to `key`
public T Get<T>(string key)
{
BinaryFormatter bf = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream())
{
// Find the correct key
foreach (DataEntry entry in entries)
{
if (entry.key == key)
{
// Hacky serialization stuff
byte[] data = entry.bytes.ToArray();
ms.Write(data, 0, data.Length);
ms.Seek(0, SeekOrigin.Begin);
return (T)bf.Deserialize(ms);
}
}
}
// Raise an exception when key is not found
throw new KeyNotFoundException();
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
public class StartScreenManager : MonoBehaviour
{
public UserList userList;
void Awake()
{
if (!File.Exists(UserList.PATH) || userList.GetUsers().Count <= 0)
{
SceneManager.LoadScene("Accounts/Scenes/UserCreationScreen");
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 183eab19332f33a48a745b7b264611fc
guid: e7cdd358c46e3f94398d91b7118e6d39
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,63 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Create new Scriptable/User")]
public class User : ScriptableObject
{
[Header("Personal data")]
// User nickname
public string username;
// User avatar
public Sprite avatar;
[Header("Personal settings")]
// TODO: set personal settings and preferences
[Header("Progress")]
// Total playtime
public double playtime;
[SerializeField]
// List of courses a user started/completed
public List<Progress> courses = new List<Progress>();
[SerializeField]
// List of minigames a user played
public List<Progress> minigames = new List<Progress>();
// Get a list of all recently started courses, returns a list of tuples of `<CourseIndex idx, float courseProgress>`
public List<Tuple<CourseIndex, float>> GetRecentCourses()
{
// TODO: return better results (for now only return all courses)
List<Tuple<CourseIndex, float>> recentCourses = new List<Tuple<CourseIndex, float>>();
foreach (Progress courseProgress in courses)
{
CourseIndex idx = courseProgress.Get<CourseIndex>("courseIndex");
float progress = courseProgress.Get<float>("courseProgress");
recentCourses.Add(Tuple.Create<CourseIndex, float>(idx, progress));
}
return recentCourses;
}
// Get a list of all recommended courses, returns a list of tuples of `<CourseIndex idx, float courseProgress>`
public List<Tuple<CourseIndex, float>> GetRecommendedCourses()
{
List<Tuple<CourseIndex, float>> recommenedCourses = new List<Tuple<CourseIndex, float>>();
if (courses.Count == 0)
{
recommenedCourses.Add(Tuple.Create<CourseIndex, float>(CourseIndex.FINGERSPELLING, 0.0f));
}
else
{
// TODO: return better results (for now only return all courses)
foreach (Progress courseProgress in courses)
{
CourseIndex idx = courseProgress.Get<CourseIndex>("courseIndex");
float progress = courseProgress.Get<float>("courseProgress");
recommenedCourses.Add(Tuple.Create<CourseIndex, float>(idx, progress));
}
}
return recommenedCourses;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3c6c5919d9f747143b377c2bc34cd28b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -18,7 +16,7 @@ public class UserButton : MonoBehaviour
void Start()
{
User user = userList.users[userList.currentUserIndex];
User user = userList.GetCurrentUser();
avatar.sprite = user.avatar;
username.text = user.username;
}

View File

@@ -1,101 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class UserCreationScreen : MonoBehaviour
{
// Max length of a username
private const int MAX_USERNAME_LENGTH = 12;
[Header("UI References")]
// Reference to the input text field for username
public TMP_InputField inputName;
// Reference to the avatar-list container
public Transform avatarsContainer;
[Header("Prefab")]
// Avatar prefab
public GameObject avatarPrefab;
// List of all sprites that are supported as avatars
public List<Sprite> sprites = new List<Sprite>();
[Header("Users List")]
// Reference to the UserList ScriptableObject
public UserList users;
[SerializeField]
// Current selected avatar
private int selectedAvatar = 0;
// List of references to avatar background sprites (so we can color them nicely)
private List<Image> avatars = new List<Image>();
void Start()
{
for (int i = 0; i < sprites.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<Button>().onClick.AddListener(() => UpdateAvatar(x));
// Store reference to image for fancy coloring
Image background = instance.GetComponent<Image>();
avatars.Add(background);
// Set background color
background.color = selectedAvatar == i ? Color.blue : Color.gray;
// Find correct component for setting the sprite
foreach (Image img in background.GetComponentsInChildren<Image>())
if (img != background)
{
img.sprite = sprites[i];
break;
}
}
}
// Update the current selected avatar
private void UpdateAvatar(int newAvatar)
{
avatars[selectedAvatar].color = Color.gray;
selectedAvatar = newAvatar;
avatars[selectedAvatar].color = Color.blue;
}
// Check if a given string is a correct username (using Regex)
static public bool IsValidUsername(string username)
{
return new Regex($@"^[abcdefghijklmnopqrstuvwxyz]{{1,{MAX_USERNAME_LENGTH}}}$").IsMatch(username);
}
// Create a new user (will be called by button)
public void CreateUser()
{
string username = inputName.text;
if (IsValidUsername(username))
{
if (!users.GetUserByUsername(username))
{
// Create a new entry in the UserList ScriptableObject
users.CreateAndAddNewUser(username, sprites[selectedAvatar]);
// TODO: change scene, for now just change to StartScreen
SceneManager.LoadScene("Common/Scenes/StartScreen");
}
// TODO: give more feedback to user
// Warn user that username already exists
else Debug.LogWarning($"Username '{username}' already exists!");
}
// TODO: give more feedback to user
// Warn user that username is invalid
else Debug.LogWarning($"Invalid username '{username}'!");
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fc3902e35c042b14f83b24498d31d587
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,47 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
[CreateAssetMenu(menuName = "Create new Scriptable/UserList")]
public class UserList : ScriptableObject
{
[Header("Template")]
// Reference to User template
public ScriptableObject userTemplate;
[Header("Users")]
// List of users
public List<User> users = new List<User>();
// Current user
public int currentUserIndex = 0;
// Create a new User
public User CreateNewUser(string name, Sprite avatar)
{
User user = ScriptableObject.CreateInstance<User>();
user.username = name;
user.avatar = avatar;
return user;
}
// Create a new User and add to list
public User CreateAndAddNewUser(string name, Sprite avatar)
{
User user = CreateNewUser(name, avatar);
users.Add(user);
EditorUtility.SetDirty(this);
AssetDatabase.CreateAsset(user, $"Assets/Common/ScriptableObjects/Users/{name}.asset");
AssetDatabase.SaveAssets();
return user;
}
// Get user by username, returns `null` if no user can be found with such name
public User GetUserByUsername(string username)
{
foreach (User user in users)
if (user.username == username) return user;
return null;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3f3d6d68c3c3db64e91cf5ec9537ccda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,176 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;
public class TestProgress : MonoBehaviour
{
[Serializable]
// Dummy struct
private struct SerializableStruct
{
public int r, g, b;
public float x, y, z;
}
private struct NonSerializableStruct
{
public int r, g, b;
public float x, y, z;
}
// Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException`
private bool AddNonSerializableStruct()
{
Progress progress = new Progress();
NonSerializableStruct nss = new NonSerializableStruct();
try { progress.AddOrUpdate<NonSerializableStruct>("key", nss); }
catch (SerializationException) { return true; }
return false;
}
// Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException`
private bool AccessInvalidKey()
{
Progress progress = new Progress();
try { progress.Get<int>("non-existing key"); }
catch (KeyNotFoundException) { return true; }
return false;
}
// Helper method, returns true if `Progress.Get(...)` throws a `InvalidCastException`
private bool AccessInvalidType()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 123456789);
try { progress.Get<double>("key"); }
catch (InvalidCastException) { return true; }
return false;
}
void Start()
{
TestNewProgress();
TestProgressAddInvalidData();
TestProgressAddDuplicateKey();
TestProgressAddInt();
TestProgressAddDouble();
TestProgressAddString();
TestProgressAddSerializableStruct();
TestProgressAddNonSerializableStruct();
TestProgressGetInvalidKey();
TestProgressGetInvalidType();
TestProgressUpdate();
TestProgressGetInt();
TestProgressGetDouble();
TestProgressGetString();
TestProgressGetStruct();
}
public void TestNewProgress()
{
Progress progress = new Progress();
Debug.Assert(progress != null);
}
public void TestProgressAddInvalidData()
{
Progress progress = new Progress();
Debug.Assert(!progress.AddOrUpdate<GameObject>("key", null));
}
public void TestProgressAddDuplicateKey()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key 1", 0);
Debug.Assert(progress.AddOrUpdate<int>("key 1", 1));
}
public void TestProgressAddInt()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<int>("key", 1));
}
public void TestProgressAddDouble()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<double>("key", 1.0));
}
public void TestProgressAddString()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<string>("key", "Hello World!"));
}
public void TestProgressAddSerializableStruct()
{
Progress progress = new Progress();
Debug.Assert(progress.AddOrUpdate<SerializableStruct>("key", new SerializableStruct()));
}
public void TestProgressAddNonSerializableStruct()
{
Debug.Assert(AddNonSerializableStruct());
}
public void TestProgressGetInvalidKey()
{
Debug.Assert(AccessInvalidKey());
}
public void TestProgressGetInvalidType()
{
Debug.Assert(AccessInvalidType());
}
public void TestProgressUpdate()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 1);
Debug.Assert(progress.Get<int>("key") == 1);
progress.AddOrUpdate<int>("key", 2);
Debug.Assert(progress.Get<int>("key") == 2);
}
public void TestProgressGetInt()
{
Progress progress = new Progress();
progress.AddOrUpdate<int>("key", 1);
Debug.Assert(progress.Get<int>("key") == 1);
}
public void TestProgressGetDouble()
{
Progress progress = new Progress();
progress.AddOrUpdate<double>("key", 1.0);
Debug.Assert(progress.Get<double>("key") == 1.0);
}
public void TestProgressGetString()
{
Progress progress = new Progress();
progress.AddOrUpdate<string>("key", "Hello World!");
Debug.Assert(progress.Get<string>("key") == "Hello World!");
}
public void TestProgressGetStruct()
{
Progress progress = new Progress();
int R = 1, G = 10, B = 100;
float X = 0.1f, Y = 0.01f, Z = 0.001f;
SerializableStruct data = new SerializableStruct { r = R, g = G, b = B, x = X, y = Y, z = Z };
progress.AddOrUpdate<SerializableStruct>("key", data);
SerializableStruct result = progress.Get<SerializableStruct>("key");
Debug.Assert(result.r == R);
Debug.Assert(result.g == G);
Debug.Assert(result.b == B);
Debug.Assert(result.x == X);
Debug.Assert(result.y == Y);
Debug.Assert(result.z == Z);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 49445c42f43d1bb488f588623826a39e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestUserCreationScreen : MonoBehaviour
{
void Start()
{
TestIsValidUsernameTrue();
TestIsValidUsernameFalse();
}
public void TestIsValidUsernameTrue()
{
foreach (char c in "abcdefghijklmnopqrstuvwxyz")
Debug.Assert(UserCreationScreen.IsValidUsername(c.ToString()));
Debug.Assert(UserCreationScreen.IsValidUsername("abcdefghijkl"));
}
public void TestIsValidUsernameFalse()
{
Debug.Assert(!UserCreationScreen.IsValidUsername(string.Empty));
foreach (char c in " \n\t0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-*/%_(){}[]\\")
Debug.Assert(!UserCreationScreen.IsValidUsername(c.ToString()));
Debug.Assert(!UserCreationScreen.IsValidUsername("abcdefghijklmnopqrstuvwxyz"));
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b6dabaf99e10900459274641f4cc9010
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: