PlatformReferenceTable.cs 2.0 KB

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