edgesnapfourDataExcelData.cs 1.7 KB

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