Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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, strNamel = rootObject.en[val].InGameName;
  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. StreamWriter streamWriter = new StreamWriter(File.Create("Assets/Character_" + rootObject.en[val].InGameName + ".cs"));//записываем текст с прочитаного файла и создаем файл
  55.  
  56. if (strNamel != "Orc_Legionnaire")
  57. {
  58.  
  59. str = str.Replace(rootObject.en[val-1].InGameName, rootObject.en[val].InGameName);
  60.  
  61. }
  62. str = str.Replace("Orc_Legionnaire", rootObject.en[val].InGameName);
  63.  
  64. val++;
  65.  
  66.  
  67.  
  68.  
  69.  
  70. streamWriter.WriteLine(str);
  71.  
  72.  
  73. streamWriter.Close();
  74.  
  75.  
  76.  
  77. }
  78.  
  79.  
  80. ///
  81.  
  82.  
  83.  
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement