Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using UnityEngine;
  2. using System;
  3. using System.Collections.Generic;
  4.  
  5. public class WebData : MonoBehaviour
  6. {
  7.     public bool isLoaded = false;
  8.    
  9.     //Profile
  10.     public string ViewerId = "";
  11.     public string Name = "";
  12.     public string Avatar = "";
  13.     public string City = "";
  14.     public string Friends = "";
  15.     public string ProfileScores = "";
  16.     public string GlobalScores = "";
  17.    
  18.     public void Start()
  19.     {
  20.         Application.ExternalCall("CallWeb");
  21.     }
  22.    
  23.     public void Update()
  24.     {
  25.         if (isLoaded) UpdatePlayerPrefs();
  26.         else LoadPlayerPrefs();
  27.     }
  28.    
  29.     public void UpdatePlayerPrefs()
  30.     {
  31.         PlayerPrefs.SetString("ViewerId", ViewerId);
  32.         PlayerPrefs.SetString("Name", Name);
  33.         PlayerPrefs.SetString("Avatar", Avatar);
  34.         PlayerPrefs.SetString("City", City);
  35.         PlayerPrefs.SetString("Friends", Friends);
  36.         PlayerPrefs.SetString("ProfileScores", ProfileScores);
  37.         PlayerPrefs.SetString("GlobalScores", GlobalScores);
  38.     }
  39.    
  40.     public void LoadPlayerPrefs()
  41.     {
  42.         ViewerId = PlayerPrefs.GetString("ViewerId", "");
  43.         Name = PlayerPrefs.GetString("Name", "");
  44.         Avatar = PlayerPrefs.GetString("Avatar", "");
  45.         City = PlayerPrefs.GetString("City", "");
  46.         Friends = PlayerPrefs.GetString("Friends", "");
  47.         ProfileScores = PlayerPrefs.GetString("ProfileScores", "");
  48.         GlobalScores = PlayerPrefs.GetString("GlobalScores", "");
  49.     }
  50.     public void SetWebData(string Data)
  51.     {
  52.         string[] DataArray = Data.Split(new char[] { '&' });
  53.        
  54.         ///
  55.        
  56.         ViewerId = DataArray[0];
  57.         Name = DataArray[1];
  58.         Avatar = DataArray[2];
  59.         City = DataArray[3];
  60.         Friends = DataArray[4];
  61.         ProfileScores = DataArray[5];
  62.         GlobalScores = DataArray[6];
  63.        
  64.         ///
  65.        
  66.         isLoaded = true;
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement