CodeTemplateFactory.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.IO;
  3. using UnityEngine;
  4. namespace GFGEditor
  5. {
  6. public class CodeTemplateFactory
  7. {
  8. public static string ConfigTemplate { get; private set; }
  9. public static string ConfigArrayTemplate { get; private set; }
  10. public static string FunctionSingleTemplate { get; private set; }
  11. public static string FunctionGroupTemplate { get; private set; }
  12. public static string FunctionAllTemplate { get; private set; }
  13. public static string FunctionAllSingleBlockTemplate { get; private set; }
  14. public static string FunctionAllGroupBlockTemplate { get; private set; }
  15. //public static string ConfigTemplateEditor { get => _configTemplateEditor; }
  16. //public static string ConfigArrayTemplateEditor { get => _configArrayTemplateEditor; }
  17. public static void Init()
  18. {
  19. ConfigTemplate = File.ReadAllText(ExcelConfig.templatePath + "Config.txt");
  20. //using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Config.txt"))
  21. //{
  22. // ConfigTemplate = sr.ReadToEnd();
  23. //}
  24. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "ConfigArray.txt"))
  25. {
  26. ConfigArrayTemplate = sr.ReadToEnd();
  27. }
  28. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionSingle.txt"))
  29. {
  30. FunctionSingleTemplate = sr.ReadToEnd();
  31. }
  32. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionGroup.txt"))
  33. {
  34. FunctionGroupTemplate = sr.ReadToEnd();
  35. }
  36. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAll.txt"))
  37. {
  38. FunctionAllTemplate = sr.ReadToEnd();
  39. }
  40. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllSingleBlock.txt"))
  41. {
  42. FunctionAllSingleBlockTemplate = sr.ReadToEnd();
  43. }
  44. using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionAllGroupBlock.txt"))
  45. {
  46. FunctionAllGroupBlockTemplate = sr.ReadToEnd();
  47. }
  48. }
  49. }
  50. }