Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System;
- using System.Collections.Generic;
- public class WebData : MonoBehaviour
- {
- public bool isLoaded = false;
- //Profile
- public string ViewerId = "";
- public string Name = "";
- public string Avatar = "";
- public string City = "";
- public string Friends = "";
- public string ProfileScores = "";
- public string GlobalScores = "";
- public void Start()
- {
- Application.ExternalCall("CallWeb");
- }
- public void Update()
- {
- if (isLoaded) UpdatePlayerPrefs();
- else LoadPlayerPrefs();
- }
- public void UpdatePlayerPrefs()
- {
- PlayerPrefs.SetString("ViewerId", ViewerId);
- PlayerPrefs.SetString("Name", Name);
- PlayerPrefs.SetString("Avatar", Avatar);
- PlayerPrefs.SetString("City", City);
- PlayerPrefs.SetString("Friends", Friends);
- PlayerPrefs.SetString("ProfileScores", ProfileScores);
- PlayerPrefs.SetString("GlobalScores", GlobalScores);
- }
- public void LoadPlayerPrefs()
- {
- ViewerId = PlayerPrefs.GetString("ViewerId", "");
- Name = PlayerPrefs.GetString("Name", "");
- Avatar = PlayerPrefs.GetString("Avatar", "");
- City = PlayerPrefs.GetString("City", "");
- Friends = PlayerPrefs.GetString("Friends", "");
- ProfileScores = PlayerPrefs.GetString("ProfileScores", "");
- GlobalScores = PlayerPrefs.GetString("GlobalScores", "");
- }
- public void SetWebData(string Data)
- {
- string[] DataArray = Data.Split(new char[] { '&' });
- ///
- ViewerId = DataArray[0];
- Name = DataArray[1];
- Avatar = DataArray[2];
- City = DataArray[3];
- Friends = DataArray[4];
- ProfileScores = DataArray[5];
- GlobalScores = DataArray[6];
- ///
- isLoaded = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement