static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } acc10042 data = (acc10042)AssetDatabase.LoadAssetAtPath(exportPath, typeof(acc10042)); if (data == null) { data = ScriptableObject.CreateInstance <acc10042> (); AssetDatabase.CreateAsset((ScriptableObject)data, exportPath); data.hideFlags = HideFlags.NotEditable; } data.sheets.Clear(); using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { IWorkbook book = null; if (Path.GetExtension(filePath) == ".xls") { book = new HSSFWorkbook(stream); } else { book = new XSSFWorkbook(stream); } foreach (string sheetName in sheetNames) { ISheet sheet = book.GetSheet(sheetName); if (sheet == null) { Debug.LogError("[QuestData] sheet not found:" + sheetName); continue; } acc10042.Sheet s = new acc10042.Sheet(); s.name = sheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; acc10042.Param p = new acc10042.Param(); cell = row.GetCell(0); p.ac_x = (cell == null ? 0.0 : cell.NumericCellValue); cell = row.GetCell(1); p.ac_y = (cell == null ? 0.0 : cell.NumericCellValue); cell = row.GetCell(2); p.ac_z = (cell == null ? 0.0 : cell.NumericCellValue); s.list.Add(p); } data.sheets.Add(s); } } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); } }
void Start() { es = Resources.Load("acc10042") as acc10042; max = es.sheets[0].list.Count; }