using System; using UnityEngine; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; namespace Data { } public enum AgreementTermsDataType{ SimplifiedChinese_1001 = 1001, TraditionalChinese_1001 = 1001, English_1001 = 1001, SimplifiedChinese_1002 = 1002, TraditionalChinese_1002 = 1002, English_1002 = 1002, SimplifiedChinese_1003 = 1003, TraditionalChinese_1003 = 1003, English_1003 = 1003, } [System.Serializable] public class AgreementTermsData { /// /// ID /// public int ID; /// /// 简体中文 /// public string SimplifiedChinese; /// /// 繁体中文 /// public string TraditionalChinese; /// /// 英文 /// public string English; } [System.Serializable] public class AgreementTermsDatas { public List AgreementTermsList = new List(); } public class AgreementTermsDataExcel { private const string _fileName = "AgreementTerms"; private string _filePath; private AgreementTermsDatas _datas; public AgreementTermsDatas Datas => _datas; public AgreementTermsDataExcel() { _filePath = $"{Application.streamingAssetsPath}/ExcelData/{_fileName}.json"; var text = File.ReadAllText(_filePath); _datas = JsonConvert.DeserializeObject(text); } public AgreementTermsData GetData(int id) { foreach (var testData in _datas.AgreementTermsList) { if (id == testData.ID) { return testData; } } throw new NullReferenceException(); } }