Xom9ik

GetValue Unity

May 10th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. [Serializable]
  2.     public class Player
  3.     {
  4.         public string username;
  5.         public string email;
  6.         public string uid;
  7.  
  8.         public string game_data_json0;
  9.         public string game_data_json1;
  10.         public string game_data_json2;
  11.         public string game_data_json3;
  12.     }
  13. // Get cookies using GetCookie Jslib
  14. public string UID = "pirUJjkkId"; // Example
  15. public Player player;
  16.  
  17. public IEnumerator GetScore()
  18.     {
  19.         WWWForm form = new WWWForm ();
  20.         player = new Player();
  21.  
  22.         player.uid = UID;
  23.         string json = JsonUtility.ToJson (player, true);
  24.         form.AddField ("arrayData", json);
  25. // CHANGE
  26.         WWW www = new WWW ("http://example-name.com/db-unity/GetValue.php", form);
  27.         yield return www;
  28.         if (www.error != null) {
  29.             Debug.Log ("Error: " + www.error);
  30.             yield break;
  31.         } else {
  32.             player = JsonUtility.FromJson<Player>(www.text);
  33.  
  34.             Debug.Log (player.uid);
  35.             Debug.Log (player.username);
  36.             Debug.Log (player.email);
  37.  
  38.             Debug.Log (player.game_data_json0);
  39.             Debug.Log (player.game_data_json1);
  40.             Debug.Log (player.game_data_json2);
  41.             Debug.Log (player.game_data_json3);
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment