Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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.  
  57.  
  58. if (strNamel != "Orc_Legionnaire")
  59. {
  60. str = str.Replace(rootObject.en[val - 1].InGameName, rootObject.en[val].InGameName);
  61. }
  62.  
  63. streamWriter.WriteLine(str);
  64.  
  65.  
  66. streamWriter.Close();
  67.  
  68. val++;
  69.  
  70.  
  71. }
  72.  
  73.  
  74. ///
  75.  
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement