Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System.IO;
  6. using Newtonsoft.Json;
  7. using System.Text;
  8. [System.Serializable]
  9. public class TemlatetClasses : JsonReadDateCharacters
  10. {
  11.  
  12.  
  13.  
  14.  
  15. [MenuItem("Assets/TemplateClasses")]
  16. static void CreateTemplate()
  17. {
  18.  
  19. int val = 0;
  20.  
  21. string path = Application.streamingAssetsPath + "/DataJsonCharacter.json";
  22.  
  23.  
  24. using (StreamReader r = new StreamReader(path, Encoding.UTF8, true))
  25. {
  26. string json = r.ReadToEnd();
  27.  
  28. JsonReadDateCharacters.rootObject = JsonConvert.DeserializeObject<RootObject>(json);
  29.  
  30.  
  31. }
  32.  
  33.  
  34.  
  35. StreamReader streamReader = new StreamReader("Assets/Templates.txt");//читаем файл
  36. string str = null, strNew;
  37. while (!streamReader.EndOfStream)
  38. {
  39.  
  40. str += streamReader.ReadLine();
  41. str += "\n";
  42.  
  43.  
  44. }
  45. streamReader.Close();
  46.  
  47.  
  48.  
  49.  
  50.  
  51. foreach (var r in rootObject.en)
  52.  
  53. {
  54.  
  55. StreamWriter streamWriter = new StreamWriter(File.Create("Assets/Character_" + rootObject.en[val].InGameName + ".cs"));//записываем текст с прочитаного файла и создаем файл
  56.  
  57.  
  58. if (str != "Orc_Legionnaire")
  59. {
  60.  
  61. str = str.Replace(rootObject.en[val].InGameName, rootObject.en[val + 1].InGameName);
  62.  
  63.  
  64. }
  65.  
  66. else
  67. {
  68. str = str.Replace("Orc_Legionnaire", rootObject.en[val].InGameName);
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. val++;
  80.  
  81.  
  82. streamWriter.WriteLine(str);
  83.  
  84.  
  85. streamWriter.Close();
  86.  
  87.  
  88. }
  89.  
  90.  
  91. ///
  92.  
  93.  
  94.  
  95. }
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement