using UnityEngine; using System.Collections; using UnityEditor; using System.Collections.Generic; using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; [CustomEditor(typeof($class))] public class $classEditor : Editor { const string path = "$excelfilepath"; const string sheetName = "$sheetname"; public override void OnInspectorGUI() { if (GUILayout.Button("Data Load")) { Load(); } DrawDefaultInspector(); } bool Load() { $class data = target as $class; ExcelDataRead excelData = new ExcelDataRead(Application.dataPath + path); ISheet sheet = excelData.GetSheet(sheetName); IRow fieldNameRow = sheet.GetRow(0); data.dataList.Clear(); IEnumerator itor = sheet.GetEnumerator(); int continueCount = 0; IRow currentRow = null; while (itor.MoveNext()) { if (continueCount < 2){ continueCount++; continue; } currentRow = itor.Current as IRow; $class.Data newData = ExcelDataSet.CreateData<$class.Data>(fieldNameRow, currentRow); if(newData!= null) data.dataList.Add(newData); } EditorUtility.SetDirty(target); return true; } }