45 lines
987 B
Plaintext
45 lines
987 B
Plaintext
using System;
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
[System.Serializable]
|
|
public class #CLASSNAME#
|
|
{
|
|
#CONSTCONTENT#
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class #CLASSNAME#s
|
|
{
|
|
public List<#CLASSNAME#> #LISTNAME# = new List<#CLASSNAME#>();
|
|
}
|
|
|
|
public class #CLASSNAME#Excel
|
|
{
|
|
private const string _fileName = "#FILENAME#";
|
|
private string _filePath;
|
|
private #CLASSNAME#s _datas;
|
|
public #CLASSNAME#s Datas => _datas;
|
|
|
|
public TestDataExcel()
|
|
{
|
|
_filePath = $"{Application.streamingAssetsPath}/ExcelData/{_fileName}.json";
|
|
var text = File.ReadAllText(_filePath);
|
|
_datas = JsonConvert.DeserializeObject<#CLASSNAME#s>(text);
|
|
}
|
|
|
|
public #CLASSNAME# GetData(int id)
|
|
{
|
|
foreach (var testData in _datas.#LISTNAME#)
|
|
{
|
|
if (id == testData.Id)
|
|
{
|
|
return testData;
|
|
}
|
|
}
|
|
|
|
throw new NullReferenceException();
|
|
}
|
|
} |