public const int MON_MAX = 10; // 1ゲームあたりの問題数 // 初期化メソッド void Start() { // AoudioSourceコンポーネントを取得 audioSource = GetComponent <AudioSource>(); // 各種変数初期化 monCnt = 0; // 問題数 yesCnt = 0; // 正解数 noCnt = 0; // 不正回数 hanteiFlg = 0; // 判定フラグ // 問題データを読み込む monTable = Resources.Load("mondaidata") as MondaiData; // 0~99 までの重複なしの乱数を作成 NoDuplicate(0, 49); // 最初に表示する問題番号を決定 monNo = numbers2[monCnt]; //monNo = 0; // 問題テキストを表示 monLable.text = monTable.sheets[0].list[monNo].mondai; kaiLable0.text = monTable.sheets[0].list[monNo].kai0; kaiLable1.text = monTable.sheets[0].list[monNo].kai1; kaiLable2.text = monTable.sheets[0].list[monNo].kai2; kaiLable3.text = monTable.sheets[0].list[monNo].kai3; }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } MondaiData data = (MondaiData)AssetDatabase.LoadAssetAtPath(exportPath, typeof(MondaiData)); if (data == null) { data = ScriptableObject.CreateInstance <MondaiData> (); 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; } MondaiData.Sheet s = new MondaiData.Sheet(); s.name = sheetName; for (int i = 1; i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); ICell cell = null; MondaiData.Param p = new MondaiData.Param(); cell = row.GetCell(0); p.mondai = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(1); p.kai0 = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(2); p.kai1 = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(3); p.kai2 = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(4); p.kai3 = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(5); p.seikai = (cell == null ? "" : cell.StringCellValue); cell = row.GetCell(6); p.kaisetu = (cell == null ? "" : cell.StringCellValue); s.list.Add(p); } data.sheets.Add(s); } } ScriptableObject obj = AssetDatabase.LoadAssetAtPath(exportPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); } }