static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } XLS_CardPack data = (XLS_CardPack)AssetDatabase.LoadAssetAtPath(exportPath, typeof(XLS_CardPack)); if (data == null) { data = ScriptableObject.CreateInstance <XLS_CardPack> (); AssetDatabase.CreateAsset((ScriptableObject)data, exportPath); data.hideFlags = HideFlags.NotEditable; } data.sheets.Clear(); using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { IWorkbook book = new HSSFWorkbook(stream); foreach (string sheetName in sheetNames) { ISheet sheet = book.GetSheet(sheetName); if (sheet == null) { Debug.LogError("[QuestData] sheet not found:" + sheetName); continue; } XLS_CardPack.Sheet s = new XLS_CardPack.Sheet(); s.name = sheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; XLS_CardPack.Param p = new XLS_CardPack.Param(); cell = row.GetCell(0); p.id = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(1); p.cardAtr = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(2); p.cardID = (int)(cell == null ? 0 : cell.NumericCellValue); cell = row.GetCell(3); p.cardLV = (int)(cell == null ? 0 : cell.NumericCellValue); s.list.Add(p); } data.sheets.Add(s); } } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); } }
void Show() { cardPacks = new List <CardPackStruct> (); List <XLS_CardPack.Sheet> sheets = DataManager.Instance.xls_CardPack.sheets; for (int i = 0; i < sheets.Count; i++) { XLS_CardPack.Sheet sheet = sheets [i]; CardPackStruct cardStr = new CardPackStruct(); cardStr.BronzeCards = new List <CardData> (); cardStr.SilverCards = new List <CardData> (); cardStr.GoldCards = new List <CardData> (); cardStr.LegendCards = new List <CardData> (); cardStr.PackName = sheet.name; for (int i2 = 0; i2 < sheet.list.Count; i2++) { XLS_CardPack.Param param = sheet.list [i2]; CardData cd = new CardData().Set(param.cardAtr, param.cardID, param.cardLV, 1); CardParam cp = new CardParam().Set(cd); switch (cp.Rea) { case 0: cardStr.BronzeCards.Add(cd); break; case 1: cardStr.SilverCards.Add(cd); break; case 2: cardStr.GoldCards.Add(cd); break; case 3: cardStr.LegendCards.Add(cd); break; } } cardPacks.Add(cardStr); } }