Game Development Reference
In-Depth Information
Vector2 _scrollServer = Vector2.zero;
ServerHiscore _serverHiscore;
void Awake () {
_localHiscore = GetComponent<LocalHiscore>();
if (_localHiscore == null) {
_localHiscore =
gameObject.AddComponent<LocalHiscore>();
}
_serverHiscore = GetComponent<ServerHiscore>();
if (_serverHiscore == null) {
_serverHiscore =
gameObject.AddComponent<ServerHiscore>();
}
}
void Start () {
_localHiscore.Initialize(maxUser);
_serverHiscore.Initialize(maxUser,phpUrl);
}
8. We are still in the UIHiscore class. We will go to the Gameover() function
to add the load and save data functions when the user clicks on the button, as
shown in the following highlighted code:
// Unity JavaScript user:
private function Gameover ()
{
if (_clickSubmit == false) {
if (GUI.Button(_buttonRect1, "SUBMIT")) {
_localHiscore.SaveUserData(_user);
_serverHiscore.SaveUserData(_user);
}
}
if (GUI.Button(_buttonRect2, "LOCAL HI-SCORE")) {
Search WWH ::




Custom Search