-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadInfo.cs
executable file
·64 lines (56 loc) · 1.66 KB
/
loadInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using UnityEngine;
using System.Collections;
using MiniJSON;
public class loadInfo : MonoBehaviour {
private IList list;
void Start () {
string strData;
WWW www = new WWW("http://balaspa.comuf.com/build.json");
while(!www.isDone) {}
if(www.error==null) {
strData = www.text;
} else {
TextAsset tas = Resources.Load("build",typeof(TextAsset))as TextAsset;
strData = tas.text;
}
IDictionary results = (IDictionary) Json.Deserialize(strData);
list = (IList) results["results"];
}
void Update () {
foreach (Transform child in this.gameObject.transform) {
if (child.gameObject.tag=="sel") {
Component[] transforms = child.gameObject.GetComponentsInChildren(typeof(Transform));
foreach (Transform comp in transforms){
if (comp.gameObject.name == "01_title") {
TextMesh texM = comp.gameObject.GetComponent(typeof(TextMesh)) as TextMesh;
string m = readData(child.gameObject.name);
texM.text = string.Format(m);
}
if (comp.gameObject.name == "03_entity") {
TextMesh texM = comp.gameObject.GetComponent(typeof(TextMesh)) as TextMesh;
string m = readData1(child.gameObject.name);
texM.text = string.Format(m);
}
}
}
}
}
string readData(string query) {
string rt = null;
foreach(IDictionary building in list) {
if(building["mesh"]as string ==query) {
rt = building["name"]as string;
}
}
return(rt);
}
string readData1(string query) {
string rt1 = null;
foreach(IDictionary building in list) {
if(building["mesh"]as string ==query) {
rt1 += string.Format ("{0} : {1} \n",building["type"],building["entity"])as string;
}
}
return(rt1);
}
}