Ejemplo n.º 1
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            BoxHelop_Sheet1 data = (BoxHelop_Sheet1)AssetDatabase.LoadAssetAtPath(exportPath, typeof(BoxHelop_Sheet1));
            if (data == null)
            {
                data = ScriptableObject.CreateInstance <BoxHelop_Sheet1> ();
                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;
                    }

                    BoxHelop_Sheet1.Sheet s = new BoxHelop_Sheet1.Sheet();
                    s.name = sheetName;

                    for (int i = 1; i < sheet.LastRowNum; i++)
                    {
                        IRow  row  = sheet.GetRow(i);
                        ICell cell = null;

                        BoxHelop_Sheet1.Param p = new BoxHelop_Sheet1.Param();

                        cell = row.GetCell(0); p.id = (int)(cell == null ? 0 : cell.NumericCellValue);
                        cell = row.GetCell(1); p.procedure = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(2); p.name = (cell == null ? "" : cell.StringCellValue);
                        cell = row.GetCell(3); p.detail = (cell == null ? "" : cell.StringCellValue);
                        s.list.Add(p);
                    }
                    data.sheets.Add(s);
                }
            }

            ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject;
            EditorUtility.SetDirty(obj);
        }
    }
Ejemplo n.º 2
0
    // Change subject and detail from XLS Data.
    public void UpdateText(SCRIPTTYPE type)
    {
        scType = type;

        BoxHelop_Sheet1.Param dataParam = boxHelpData.sheets [0].list
                                          .Where(data => data.procedure == scType.ToString())
                                          .FirstOrDefault();

        subjectText.text = dataParam.name;
        detailText.text  = dataParam.detail;
    }