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 #CLASSNAME#Excel() { _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(); } }