AtlasReferenceTable.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. namespace AtlasUtility
  2. {
  3. using UnityEditor;
  4. using System;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Collections.Generic;
  8. public class AtlasReferenceTable
  9. {
  10. #region Variable
  11. protected static string ReferenceTablePath
  12. {
  13. get { return AssetDatabase.GetAssetPath(InstanceManager.SearchInstance<AtlasUtility>().AtlasReferenceTable); }
  14. }
  15. #endregion
  16. public static List<AtlasReferencePair> ReadAllLine()
  17. {
  18. StreamReader streamReader = new StreamReader(ReferenceTablePath);
  19. string referenceTable = streamReader.ReadToEnd().Trim();
  20. streamReader.Close();
  21. if (referenceTable == "")
  22. {
  23. return new List<AtlasReferencePair>();
  24. }
  25. else
  26. {
  27. List<AtlasReferencePair> list = new List<AtlasReferencePair>();
  28. foreach (var content in referenceTable.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList())
  29. {
  30. list.Add(new AtlasReferencePair(content));
  31. }
  32. return list;
  33. }
  34. }
  35. public static void WriteAllLine(List<AtlasReferencePair> referencePairList, bool append = false)
  36. {
  37. List<string> lineList = new List<string>();
  38. foreach (var referencePair in referencePairList)
  39. {
  40. lineList.Add(referencePair.Content);
  41. }
  42. WriteAllLine(lineList, append);
  43. }
  44. public static void WriteAllLine(List<string> lineList, bool append = false)
  45. {
  46. StreamWriter streamWriter = new StreamWriter(ReferenceTablePath, append);
  47. for (int i = 0; i < lineList.Count; i++)
  48. {
  49. streamWriter.WriteLine(lineList[i]);
  50. }
  51. streamWriter.Close();
  52. }
  53. }
  54. }