thieumao

Set text label, next sceen, read json with Unity3D

Apr 3rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class nextScreen : MonoBehaviour {
  5.  
  6.     // Use this for initialization
  7.     public void chuyenManHinh(){
  8.         Debug.Log ("Thieu mao");
  9.         //Application.LoadLevel (1);
  10.         UILabel subtitle = GameObject.Find("LabelHienThi").GetComponent<UILabel>();
  11.         subtitle.text = "Toan dep trai";
  12.     }
  13.  
  14.     IEnumerator Start()
  15.     {
  16.         //Load JSON data from a URL
  17.         string url = "http://paultondeur.com/files/2010/UnityExternalJSONXML/books.json";
  18.         url = "https://dl.dropboxusercontent.com/u/119735704/API/store/link.txt";
  19.         WWW www = new WWW(url);
  20.        
  21.         //Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
  22.         yield return www;
  23.         if (www.error == null)
  24.         {
  25.             //Sucessfully loaded the JSON string
  26.             Debug.Log("Chuoi json: " + www.text);
  27.            
  28.             //Process books found in JSON file
  29.             //ProcessBooks(www.text);
  30.         }
  31.         else
  32.         {
  33.             Debug.Log("Loi: " + www.error);
  34.         }
  35.        
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment