EludeBeastOneExcelData.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*Auto Create, Don't Edit !!!*/
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. using System;
  5. using System.IO;
  6. [Serializable]
  7. public class EludeBeastOneExcelItem : ExcelItemBase
  8. {
  9. public int Grade;
  10. public int beginOne;
  11. public int finishOne;
  12. public int beginTwo;
  13. public int finishTwo;
  14. public float delayTime;
  15. public int Score;
  16. }
  17. [CreateAssetMenu(fileName = "EludeBeastOneExcelData", menuName = "Excel To ScriptableObject/Create EludeBeastOneExcelData", order = 1)]
  18. public class EludeBeastOneExcelData : ExcelDataBase<EludeBeastOneExcelItem>
  19. {
  20. }
  21. #if UNITY_EDITOR
  22. public class EludeBeastOneAssetAssignment
  23. {
  24. public static bool CreateAsset(List<Dictionary<string, string>> allItemValueRowList, string excelAssetPath)
  25. {
  26. if (allItemValueRowList == null || allItemValueRowList.Count == 0)
  27. return false;
  28. int rowCount = allItemValueRowList.Count;
  29. EludeBeastOneExcelItem[] items = new EludeBeastOneExcelItem[rowCount];
  30. for (int i = 0; i < items.Length; i++)
  31. {
  32. items[i] = new EludeBeastOneExcelItem();
  33. items[i].Grade = Convert.ToInt32(allItemValueRowList[i]["Grade"]);
  34. items[i].beginOne = Convert.ToInt32(allItemValueRowList[i]["beginOne"]);
  35. items[i].finishOne = Convert.ToInt32(allItemValueRowList[i]["finishOne"]);
  36. items[i].beginTwo = Convert.ToInt32(allItemValueRowList[i]["beginTwo"]);
  37. items[i].finishTwo = Convert.ToInt32(allItemValueRowList[i]["finishTwo"]);
  38. items[i].delayTime = Convert.ToSingle(allItemValueRowList[i]["delayTime"]);
  39. items[i].Score = Convert.ToInt32(allItemValueRowList[i]["Score"]);
  40. }
  41. EludeBeastOneExcelData excelDataAsset = ScriptableObject.CreateInstance<EludeBeastOneExcelData>();
  42. excelDataAsset.items = items;
  43. if (!Directory.Exists(excelAssetPath))
  44. Directory.CreateDirectory(excelAssetPath);
  45. string pullPath = excelAssetPath + "/" + typeof(EludeBeastOneExcelData).Name + ".asset";
  46. UnityEditor.AssetDatabase.DeleteAsset(pullPath);
  47. UnityEditor.AssetDatabase.CreateAsset(excelDataAsset, pullPath);
  48. UnityEditor.AssetDatabase.Refresh();
  49. return true;
  50. }
  51. }
  52. #endif