ServersuffixDataExcelData.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ServersuffixDataExcelItem : ExcelItemBase
  8. {
  9. public string Serversuffix;
  10. public string Explain;
  11. }
  12. [CreateAssetMenu(fileName = "ServersuffixDataExcelData", menuName = "Excel To ScriptableObject/Create ServersuffixDataExcelData", order = 1)]
  13. public class ServersuffixDataExcelData : ExcelDataBase<ServersuffixDataExcelItem>
  14. {
  15. }
  16. #if UNITY_EDITOR
  17. public class ServersuffixDataAssetAssignment
  18. {
  19. public static bool CreateAsset(List<Dictionary<string, string>> allItemValueRowList, string excelAssetPath)
  20. {
  21. if (allItemValueRowList == null || allItemValueRowList.Count == 0)
  22. return false;
  23. int rowCount = allItemValueRowList.Count;
  24. ServersuffixDataExcelItem[] items = new ServersuffixDataExcelItem[rowCount];
  25. for (int i = 0; i < items.Length; i++)
  26. {
  27. items[i] = new ServersuffixDataExcelItem();
  28. items[i].Serversuffix = allItemValueRowList[i]["Serversuffix"];
  29. items[i].Explain = allItemValueRowList[i]["Explain"];
  30. }
  31. ServersuffixDataExcelData excelDataAsset = ScriptableObject.CreateInstance<ServersuffixDataExcelData>();
  32. excelDataAsset.items = items;
  33. if (!Directory.Exists(excelAssetPath))
  34. Directory.CreateDirectory(excelAssetPath);
  35. string pullPath = excelAssetPath + "/" + typeof(ServersuffixDataExcelData).Name + ".asset";
  36. UnityEditor.AssetDatabase.DeleteAsset(pullPath);
  37. UnityEditor.AssetDatabase.CreateAsset(excelDataAsset, pullPath);
  38. UnityEditor.AssetDatabase.Refresh();
  39. return true;
  40. }
  41. }
  42. #endif