FM/Assets/Scripts/Runtime/Generate/Excel2CS/AgreementTermsData.cs

80 lines
1.6 KiB
C#

using System;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using HK;
namespace Data
{
public enum AgreementTermsDataType{
Desc_1001 = 1001,
SimplifiedChinese_1001 = 1001,
English_1001 = 1001,
Desc_1002 = 1002,
SimplifiedChinese_1002 = 1002,
English_1002 = 1002,
Desc_1003 = 1003,
SimplifiedChinese_1003 = 1003,
English_1003 = 1003,
Desc_1004 = 1004,
SimplifiedChinese_1004 = 1004,
English_1004 = 1004,
}
[System.Serializable]
public class AgreementTermsData
{
/// <summary>
/// ID
/// </summary>
public int ID;
/// <summary>
/// 描述
/// </summary>
public string Desc;
/// <summary>
/// 中文
/// </summary>
public string SimplifiedChinese;
/// <summary>
/// 英文
/// </summary>
public string English;
}
[System.Serializable]
public class AgreementTermsDatas
{
public List<AgreementTermsData> AgreementTermsList = new List<AgreementTermsData>();
}
public class AgreementTermsDataExcel
{
private const string _fileName = "AgreementTerms";
private string _filePath;
private AgreementTermsDatas _datas;
public AgreementTermsDatas Datas => _datas;
public AgreementTermsDataExcel()
{
_filePath = $"Assets/Res/ExcelData/{_fileName}.json";
var text = ResourcesManager.Instance.Load<TextAsset>(_filePath);
_datas = JsonConvert.DeserializeObject<AgreementTermsDatas>(text.text);
}
public AgreementTermsData GetData(int id)
{
foreach (var testData in _datas.AgreementTermsList)
{
if (id == testData.ID)
{
return testData;
}
}
throw new NullReferenceException();
}
}}