-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFileLoader.cs
44 lines (38 loc) · 1.4 KB
/
FileLoader.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
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Text;
public class FileLoader : MonoBehaviour {
private FileReader reader;
private FileReader reader1;
private Text _text;
// Use this for initialization
void Start () {
_text = FindObjectOfType<Text>();
#if UNITY_EDITOR
string basepath = Application.dataPath + "/StreamingAssets/QCAR/VRGame.xml";
string basepath1 = Application.dataPath + "/StreamingAssets/QCAR/Tarmac.xml";
#elif UNITY_IPHONE
string basepath = Application.dataPath +"/Raw/";
#elif UNITY_ANDROID
string basepath = "jar:file://" + Application.dataPath + "!/assets/QCAR/VRGame.xml";
string basepath1 = "jar:file://" + Application.dataPath + "/StreamingAssets/QCAR/Tarmac.xml";
#endif
reader = new FileReader();
reader1 = new FileReader();
reader1.LoadFile(basepath1);
reader.LoadFile(basepath);
StartCoroutine(WaitForLoadFile());
StartCoroutine(WaitForLoadFile1());
}
// Update is called once per frame
IEnumerator WaitForLoadFile () {
yield return new WaitUntil(() => { return reader.LoadCompleted; });
_text.text = Encoding.UTF8.GetString(reader.Buffer);
}
IEnumerator WaitForLoadFile1()
{
yield return new WaitUntil(() => { return reader1.LoadCompleted; });
_text.text += Encoding.UTF8.GetString(reader1.Buffer);
}
}