using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using static InterfaceManager; public class ReadLoginInfo : MonoBehaviour { /// /// 判断跳入什么考试还是练习模式 /// public MainSelect mainselect; /// /// 获取登入时间 /// public string time; /// /// 获取接口 /// public MainRoot mainRoot = new MainRoot(); public List examContents = new List(); private void Awake() { Init(); } private void Init() { DontDestroyOnLoad(this.gameObject); string path = Application.streamingAssetsPath + @"\start.ini"; if (File.Exists(path)) { File.WriteAllText(Application.streamingAssetsPath + "/start.ini", "1"); } time = DateTime.Now.ToString(); PlayerPrefs.SetString("time", time); LoadInfo(); } /// /// 通过判断跳转场景 /// private void LoadInfo() { string str; string path = Application.streamingAssetsPath + @"\info.ini"; Debug.Log(path); if (File.Exists(path)) { str = File.ReadAllText(path); Debug.Log(str); string[] data = str.Split(new char[] { ';' }); string[] datas = data[1].Split(new char[] { ',' }); if (0 < datas[8].Length) { Debug.Log("进来了"); IpAddress = "http://" + datas[8]; } if (datas[0] == "lyht") { if (datas[1] == "0") { PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); mainselect.practicebutton.onClick.Invoke(); } else if (datas[1] == "1") { PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); PlayerPrefs.SetString("Time", datas[6]); PlayerPrefs.SetInt("calssID", int.Parse(datas[7])); mainselect.examinationbutton.onClick.Invoke(); } } else if (datas[0] == "dfhs") { if (datas[1] == "0") { PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); mainselect.Electricchargeexercise.onClick.Invoke(); } else if (datas[1] == "1") { Debug.Log(int.Parse(datas[2])); PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); PlayerPrefs.SetString("Time", datas[6]); PlayerPrefs.SetInt("calssID", int.Parse(datas[7])); mainselect.Electricityfeetest.onClick.Invoke(); } } else if (datas[0] == "gdht") { if (datas[1] == "0") { Debug.Log(datas[2]); PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); mainselect.Powersupplyexercise.onClick.Invoke(); } else if (datas[1] == "1") { PlayerPrefs.SetInt("Id", int.Parse(datas[2])); PlayerPrefs.SetString("UserId", datas[3]); PlayerPrefs.SetString("Name", datas[4]); PlayerPrefs.SetString("Time", datas[6]); PlayerPrefs.SetInt("calssID", int.Parse(datas[7])); mainselect.Powersupplytest.onClick.Invoke(); } } } } void Update() { } }