Game Development Reference
In-Depth Information
Objective complete - mini debriefing
In this step, we created the
UserData
script that implements from the
ICompar-
able<T>
generic interface to create a custom sort for the
UserData
object. We also ad-
ded
System.Serialiable
to the
UserData
script to enable the ability to serialize
this object and save it in a later step. Then, we added the
UserData
object in the
UIHis-
core
script and created the username input text field. Finally, we created the
Hiscore
class that will be the base class for the
LocalHiscore
and
ServerHiscore
scripts in
the next step. In this
Hiscore
class, we created
List<UserData>
to store all the users'
data. Then, we sorted them using
_users.Sort()
to sort from the lowest to the highest
score. However, we need to show the score from the highest, so we also use
users.Reverse()
to reverse the sorting object.