InTerra_MaterialCreator.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEditor;
  4. using System.IO;
  5. using System.Linq;
  6. namespace InTerra
  7. {
  8. public class InTerra_MaterialCreator : EditorWindow
  9. {
  10. static Material SelectedMaterial;
  11. static string baseName = "";
  12. static string path = "";
  13. static string newBase = "";
  14. static List<string> createdBaseNames;
  15. static Dictionary<string, Terrain> newMaterial;
  16. static Dictionary<Material, Terrain> notTageddMat;
  17. static Dictionary<Renderer, Terrain> materialRendTerrain;
  18. static Dictionary<Renderer, Terrain> allRendTerrain;
  19. static List<Material> relatedMaterials;
  20. static List<Renderer> baseNameRenderers;
  21. static Terrain[] terrains;
  22. bool changingName;
  23. bool wrongName;
  24. bool setedTags;
  25. static bool baseNameAlreadyExist;
  26. Vector2 ScrollPos;
  27. Vector2 ScrollPos2;
  28. Vector2 ScrollPos3;
  29. //===============================================================================================
  30. //----------------------| MULTIPLE TERRAINS MATERIALS CREATOR |-----------------------------
  31. //===============================================================================================
  32. public static void OpenWindow(Material Mat, Dictionary<Renderer, Terrain> allRendTer, List<Material> relatedMat, string bName)
  33. {
  34. InTerra_MaterialCreator window = GetWindow<InTerra_MaterialCreator>(true, "Multiple Terrains Materials Creator", true);
  35. baseNameAlreadyExist = relatedMat != null && Mat && relatedMat.Count > 0 && Mat.GetTag("BaseName", false).Length == 0;
  36. Vector2 size = baseNameAlreadyExist ? new Vector2(809, 475) : new Vector2(809, 390);
  37. window.minSize = size;
  38. window.maxSize = size;
  39. InTerra_Data.CenterOnMainWin(window);
  40. SelectedMaterial = Mat;
  41. baseName = bName;
  42. path = DirectoryPath(SelectedMaterial);
  43. if (SelectedMaterial != null)
  44. {
  45. terrains = Terrain.activeTerrains;
  46. newMaterial = new Dictionary<string, Terrain>();
  47. createdBaseNames = new List<string>();
  48. notTageddMat = new Dictionary<Material, Terrain>();
  49. allRendTerrain = allRendTer;
  50. materialRendTerrain = new Dictionary<Renderer, Terrain>();
  51. relatedMaterials = relatedMat;
  52. baseNameRenderers = new List<Renderer>();
  53. RendededsOfMaterial(allRendTer);
  54. Material[] materials = Resources.FindObjectsOfTypeAll(typeof(Material)) as Material[];
  55. foreach(Material mat in materials)
  56. {
  57. string baseName = mat.GetTag("BaseName", false);
  58. if (baseName.Length > 0)
  59. {
  60. createdBaseNames.Add(baseName);
  61. }
  62. }
  63. CreateNewMatList();
  64. }
  65. newBase = baseName;
  66. }
  67. void OnGUI()
  68. {
  69. if (!SelectedMaterial || (newMaterial == null || newMaterial.Count == 0) && (relatedMaterials == null || relatedMaterials.Count == 0) && (notTageddMat == null || notTageddMat.Count == 0))
  70. {
  71. Close();
  72. }
  73. var normalStyle = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft };
  74. var wrongStyle = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft};
  75. wrongStyle.normal.textColor = Color.red;
  76. wrongStyle.hover.textColor = Color.red;
  77. var warningStyle = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft };
  78. warningStyle.normal.textColor = new Color(1.0f, 0.5f, 0.0f);
  79. warningStyle.hover.textColor = new Color(1.0f, 0.5f, 0.0f);
  80. string labelInfo = "";
  81. if (setedTags)
  82. {
  83. baseNameAlreadyExist = false;
  84. setedTags = false;
  85. }
  86. //----------------------| EXISTING BASE NAME |-----------------------------
  87. if (baseNameAlreadyExist)
  88. {
  89. GUIStyle breakingLabelStyle = new GUIStyle(GUI.skin.label) { wordWrap = true, alignment = TextAnchor.MiddleLeft, richText = true };
  90. using (new GUILayout.HorizontalScope(EditorStyles.helpBox))
  91. {
  92. EditorGUILayout.LabelField(EditorGUIUtility.IconContent("console.warnicon"), GUILayout.Height(30), GUILayout.Width(30));
  93. EditorGUILayout.LabelField("The Material name is the same as the Base name <b>" + baseName + "</b> of already created set of Materials.", breakingLabelStyle);
  94. }
  95. if (GUILayout.Button("Replace Material \"" + baseName + "\" With Already Created Material(s) and Create New If Needed"))
  96. {
  97. CreateMaterials();
  98. }
  99. EditorGUILayout.Space();
  100. GUI.enabled = false;
  101. }
  102. //----------------------| BASE NAME |-----------------------------
  103. using (new GUILayout.HorizontalScope())
  104. {
  105. EditorGUILayout.LabelField("Materials Base Name:", EditorStyles.miniLabel, GUILayout.Width(115));
  106. if (!changingName)
  107. {
  108. GUILayout.Label(baseName, new GUIStyle(EditorStyles.helpBox) { wordWrap = false, fontSize = 12}, GUILayout.Width(425));
  109. string tooltip = "";
  110. if (wrongName)
  111. {
  112. GUI.enabled = false;
  113. tooltip = "You cannot change Base Name if some materials has incorrect names.";
  114. }
  115. if (GUILayout.Button(new GUIContent() { text = "Change Base Name", tooltip = tooltip }, EditorStyles.miniButton))
  116. {
  117. changingName = true;
  118. }
  119. }
  120. else
  121. {
  122. RenameField(ref changingName, true);
  123. }
  124. }
  125. //----------------------| PATH |-----------------------------
  126. using (new GUILayout.HorizontalScope())
  127. {
  128. EditorGUILayout.LabelField("Saving Path:", EditorStyles.miniLabel, GUILayout.Width(115));
  129. using (new GUILayout.HorizontalScope())
  130. {
  131. GUILayout.TextField(path, new GUIStyle(EditorStyles.helpBox) { wordWrap = false }, GUILayout.Width(425));
  132. GUI.enabled = (relatedMaterials == null || relatedMaterials.Count == 0) && (notTageddMat == null || notTageddMat.Count == 0);
  133. if (GUILayout.Button(new GUIContent() { text = "Change", tooltip = "You cannot change the folder if there are already created Materials with this Base name." }, EditorStyles.miniButton))
  134. {
  135. string absPath = EditorUtility.SaveFolderPanel("Save Materials to folder", path, "");
  136. if (absPath.Contains(Application.dataPath))
  137. {
  138. path = absPath.Substring(absPath.IndexOf("Assets"));
  139. }
  140. else if (!string.IsNullOrEmpty(absPath))
  141. {
  142. path = absPath;
  143. }
  144. }
  145. GUI.enabled = !baseNameAlreadyExist;
  146. }
  147. }
  148. Repaint();
  149. EditorGUILayout.Space();
  150. using (new GUILayout.HorizontalScope())
  151. {
  152. using (new GUILayout.VerticalScope())
  153. {
  154. //----------------------| NOT TAGED MATERIALS |-----------------------------
  155. if (notTageddMat != null && notTageddMat.Count > 0)
  156. {
  157. Vector2 size = new Vector2(809, 390);
  158. minSize = size;
  159. maxSize = size;
  160. using (new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(400)))
  161. {
  162. EditorGUILayout.HelpBox("Following Materials are created, but do not have tags for relation recognizing.", MessageType.Warning);
  163. ScrollPos2 = EditorGUILayout.BeginScrollView(ScrollPos2);
  164. foreach (var mat in notTageddMat.Keys)
  165. {
  166. labelInfo = "\n\nThis Material does not have needed Tags.";
  167. GUIStyle labelStyle = warningStyle;
  168. if (!InTerra_Data.CheckObjectShader(mat))
  169. {
  170. labelInfo += "\n\nThis Material does not have InTerra shader.";
  171. labelStyle = wrongStyle;
  172. }
  173. if (GUILayout.Button(new GUIContent() { text = mat.name, tooltip = AssetDatabase.GetAssetPath(mat) + labelInfo }, labelStyle))
  174. {
  175. EditorGUIUtility.PingObject(mat);
  176. }
  177. }
  178. EditorGUILayout.EndScrollView();
  179. }
  180. using (new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(400)))
  181. {
  182. SetTags();
  183. }
  184. }
  185. //----------------------| NEW MATERIALS FOR CREATION |-----------------------------
  186. if (newMaterial != null && !(newMaterial.Count == 0 && notTageddMat.Count > 0))
  187. {
  188. using (new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(400)))
  189. {
  190. EditorGUILayout.LabelField("Materials that can be created:", EditorStyles.helpBox);
  191. {
  192. ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos);
  193. foreach (var matName in newMaterial.Keys)
  194. {
  195. GUILayout.Label(matName, normalStyle);
  196. }
  197. EditorGUILayout.EndScrollView();
  198. }
  199. GUI.enabled = newMaterial.Count > 0;
  200. }
  201. using (new GUILayout.HorizontalScope(EditorStyles.helpBox))
  202. {
  203. if (GUILayout.Button(" \n Create and Assign Materials \n ", new GUIStyle(GUI.skin.button) { fontStyle = FontStyle.Bold }))
  204. {
  205. CreateMaterials();
  206. if (!InTerra_Setting.DisableAllAutoUpdates) InTerra_Data.UpdateTerrainData(true);
  207. }
  208. }
  209. GUI.enabled = !baseNameAlreadyExist;
  210. }
  211. }
  212. using (new GUILayout.VerticalScope())
  213. {
  214. //----------------------| CREATED MATERIALS |-----------------------------
  215. using (new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.Width(400)))
  216. {
  217. EditorGUILayout.LabelField("Created Materials:", EditorStyles.helpBox);
  218. if (notTageddMat != null && relatedMaterials != null)
  219. {
  220. ScrollPos3 = EditorGUILayout.BeginScrollView(ScrollPos3);
  221. foreach (var mat in relatedMaterials)
  222. {
  223. if (!mat) Close();
  224. GUIStyle labelStyle = normalStyle;
  225. if (mat && mat.name != TagsName(mat))
  226. {
  227. labelInfo = "\n\nThis Material Name and Tags does not match.";
  228. labelStyle = warningStyle;
  229. wrongName = true;
  230. }
  231. if(!InTerra_Data.CheckObjectShader(mat))
  232. {
  233. labelInfo += "\n\nThis Material does not have InTerra shader.";
  234. labelStyle = wrongStyle;
  235. }
  236. if (GUILayout.Button(new GUIContent() { text = mat.name, tooltip = AssetDatabase.GetAssetPath(mat) + labelInfo }, labelStyle))
  237. {
  238. EditorGUIUtility.PingObject(mat);
  239. }
  240. }
  241. EditorGUILayout.EndScrollView();
  242. }
  243. }
  244. GUI.enabled = (relatedMaterials != null && relatedMaterials.Count > 0) && !baseNameAlreadyExist;
  245. if (wrongName)
  246. {
  247. EditorGUILayout.HelpBox("Some materials has incorect names or tags, please fix the issue!", MessageType.Warning);
  248. }
  249. DeleteMaterials(SelectedMaterial);
  250. }
  251. }
  252. }
  253. void DeleteMaterials(Material SelectedMaterial)
  254. {
  255. using (new GUILayout.HorizontalScope(EditorStyles.helpBox))
  256. {
  257. if (GUILayout.Button(" \n Delete Created Materials and Replace them with One...\n ", new GUIStyle(GUI.skin.button) { fontStyle = FontStyle.Bold }))
  258. {
  259. InTerra_DeleteMaterials.OpenWindow(baseName, relatedMaterials, baseNameRenderers);
  260. }
  261. }
  262. }
  263. void RenameField(ref bool namingActive, bool renameBaseName)
  264. {
  265. using (new GUILayout.HorizontalScope())
  266. {
  267. newBase = EditorGUILayout.TextField(newBase, GUILayout.Width(425));
  268. GUI.SetNextControlName("RenameOk");
  269. if (GUILayout.Button("OK"))
  270. {
  271. namingActive = false;
  272. if (newBase != baseName)
  273. {
  274. if (NewBaseNameCheck(newBase))
  275. {
  276. if (renameBaseName)
  277. {
  278. if (EditorUtility.DisplayDialog("InTerra Renaming", "Renaming of Base name(s) cannot be undone. Do you want to continue?", "Yes", "Cancel"))
  279. {
  280. Rename(newBase);
  281. CreateNewMatList();
  282. }
  283. else
  284. {
  285. newBase = baseName;
  286. }
  287. }
  288. else
  289. {
  290. relatedMaterials.Clear();
  291. baseName = newBase;
  292. CreateNewMatList();
  293. baseNameAlreadyExist = false;
  294. namingActive = false;
  295. Vector2 size = new Vector2(809, 390);
  296. minSize = size;
  297. maxSize = size;
  298. }
  299. }
  300. else
  301. {
  302. newBase = baseName;
  303. }
  304. GUI.FocusControl("CancelButton");
  305. }
  306. }
  307. GUI.SetNextControlName("CancelButton");
  308. if (GUILayout.Button("Cancel"))
  309. {
  310. namingActive = false;
  311. newBase = baseName;
  312. Repaint();
  313. GUI.FocusControl("CancelButton");
  314. }
  315. }
  316. }
  317. void Rename(string newBaseName)
  318. {
  319. bool fileExist = false;
  320. List<string> rename = new List<string>();
  321. string fullPath;
  322. if (relatedMaterials != null)
  323. {
  324. Material[] materials = Resources.FindObjectsOfTypeAll(typeof(Material)) as Material[];
  325. foreach (var mat in relatedMaterials)
  326. {
  327. string directoryPath = DirectoryPath(mat);
  328. fullPath = directoryPath + "/" + newBaseName + "_" + mat.GetTag("TerrainName", false) + ".mat";
  329. if (File.Exists(fullPath))
  330. {
  331. fileExist = true;
  332. }
  333. }
  334. if (newMaterial != null)
  335. {
  336. foreach (string matName in newMaterial.Keys)
  337. {
  338. fullPath = path + "/" + newBaseName + "_" + newMaterial[matName].name + ".mat";
  339. if (File.Exists(fullPath) && ((Material)AssetDatabase.LoadAssetAtPath(fullPath, typeof(Material))).GetTag("BaseName", false).Length > 0)
  340. {
  341. fileExist = true;
  342. }
  343. }
  344. }
  345. if (fileExist)
  346. {
  347. EditorUtility.DisplayDialog("InTerra", "Base name could not be changed because there already are file(s) with such name(s).", "Ok");
  348. newBase = baseName;
  349. }
  350. else
  351. {
  352. foreach (var mat in relatedMaterials)
  353. {
  354. if (File.Exists(DirectoryPath(mat) + "/" + newBaseName + "_" + mat.GetTag("TerrainName", false) + ".mat"))
  355. {
  356. EditorUtility.DisplayDialog("InTerra", "Renaming of the file \"" + AssetDatabase.GetAssetPath(mat) + "\" failed.", "Ok"); ;
  357. }
  358. else
  359. {
  360. AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(mat), newBaseName + "_" + mat.GetTag("TerrainName", false));
  361. AssetDatabase.Refresh();
  362. if (mat.name == Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(mat)))
  363. {
  364. mat.SetOverrideTag("BaseName", newBaseName);
  365. }
  366. }
  367. }
  368. baseName = newBaseName;
  369. }
  370. }
  371. CreateNewMatList();
  372. }
  373. bool NewBaseNameCheck(string newBaseName)
  374. {
  375. createdBaseNames.Clear();
  376. bool baseNameOk = false;
  377. bool dotInTerrainName = false;
  378. foreach (Terrain terrain in terrains)
  379. {
  380. if (terrain.name.Contains("."))
  381. {
  382. dotInTerrainName = true;
  383. }
  384. }
  385. if (createdBaseNames.Contains(newBaseName))
  386. {
  387. EditorUtility.DisplayDialog("InTerra", "This Base name is already used for different set of Materials, please choose a different one.", "Ok");
  388. }
  389. else if (InvalidFileChars(newBaseName))
  390. {
  391. EditorUtility.DisplayDialog("InTerra", "The Base name contains invalid characters.", "Ok");
  392. }
  393. else if (dotInTerrainName)
  394. {
  395. EditorUtility.DisplayDialog("InTerra", "The change of base name is not allowed if some Terrain names contains a dot character because of Unity bug.", "Ok");
  396. }
  397. else
  398. {
  399. baseNameOk = true;
  400. }
  401. return baseNameOk;
  402. }
  403. static bool InvalidFileChars(string flieName)
  404. {
  405. bool invalidCharacter = string.IsNullOrEmpty(flieName) || flieName.Substring(0, 1) == " ";
  406. char[] invalidFileChars = Path.GetInvalidFileNameChars();
  407. foreach (char invChar in invalidFileChars)
  408. {
  409. invalidCharacter = invalidCharacter || flieName.Contains(invChar);
  410. }
  411. return invalidCharacter;
  412. }
  413. static void CreateNewMatList()
  414. {
  415. newMaterial.Clear();
  416. notTageddMat.Clear();
  417. foreach (Terrain terrain in terrains)
  418. {
  419. string newMatName = baseName + "_" + terrain.name;
  420. string pathAndFile = path + "/" + baseName + "_" + terrain.name + ".mat";
  421. if (!File.Exists(pathAndFile) && materialRendTerrain.ContainsValue(terrain))
  422. {
  423. newMaterial.Add(newMatName, terrain);
  424. }
  425. else
  426. {
  427. Material mat = (Material)AssetDatabase.LoadAssetAtPath(pathAndFile, typeof(Material));
  428. if (mat && mat.GetTag("BaseName", false).Length == 0 && !notTageddMat.ContainsKey(mat))
  429. {
  430. notTageddMat.Add(mat, terrain);
  431. }
  432. }
  433. }
  434. }
  435. void CreateMaterials()
  436. {
  437. if (!Directory.Exists(path) || !(path.Length > 3))
  438. {
  439. EditorUtility.DisplayDialog("InTerra", "Materials cannot be created because the saving path is not valid.", "Ok");
  440. }
  441. else
  442. {
  443. Material mat;
  444. Terrain[] terrains = Terrain.activeTerrains;
  445. Dictionary<Renderer, Material> objMat = new Dictionary<Renderer, Material>();
  446. foreach (Terrain terrain in terrains)
  447. {
  448. if (materialRendTerrain.ContainsValue(terrain))
  449. {
  450. string pathAndFile = path + "/" + baseName + "_" + terrain.name + ".mat";
  451. if (!File.Exists(pathAndFile) && newMaterial.ContainsKey(baseName + "_" + terrain.name))
  452. {
  453. mat = new Material(SelectedMaterial.shader);
  454. mat.CopyPropertiesFromMaterial(SelectedMaterial);
  455. mat.SetOverrideTag("BaseName", baseName);
  456. mat.SetOverrideTag("TerrainName", terrain.name);
  457. AssetDatabase.CreateAsset(mat, pathAndFile);
  458. AssetDatabase.SaveAssets();
  459. }
  460. else
  461. {
  462. mat = (Material)AssetDatabase.LoadAssetAtPath(pathAndFile, typeof(Material));
  463. }
  464. foreach (Renderer rend in materialRendTerrain.Keys)
  465. {
  466. if (materialRendTerrain[rend] == terrain)
  467. {
  468. objMat.Add(rend, mat);
  469. }
  470. }
  471. if (!InTerra_Setting.DisableAllAutoUpdates) InTerra_Data.UpdateTerrainData(true);
  472. }
  473. }
  474. Undo.RecordObjects(objMat.Keys.ToArray(), "InTerra Created/Assigned Materials");
  475. foreach(Renderer rend in objMat.Keys)
  476. {
  477. rend.sharedMaterial = objMat[rend];
  478. }
  479. Close();
  480. }
  481. }
  482. static void RendededsOfMaterial(Dictionary<Renderer, Terrain> allRendTer)
  483. {
  484. materialRendTerrain.Clear();
  485. foreach (Renderer rend in allRendTer.Keys)
  486. {
  487. if (rend.sharedMaterial.GetTag("BaseName", false) == baseName) baseNameRenderers.Add(rend);
  488. foreach (Material mat in rend.sharedMaterials)
  489. {
  490. if ((mat != null && mat.shader.name != null && (mat == SelectedMaterial)) || rend.sharedMaterial.GetTag("BaseName", false) == baseName)
  491. {
  492. Vector2 position = new Vector2(rend.bounds.center.x, rend.bounds.center.z);
  493. foreach (Terrain terrain in terrains)
  494. {
  495. if (InTerra_Data.CheckPosition(terrain, position))
  496. {
  497. materialRendTerrain.Add(rend, terrain);
  498. }
  499. }
  500. }
  501. }
  502. }
  503. }
  504. void SetTags()
  505. {
  506. Terrain[] terrains = Terrain.activeTerrains;
  507. if (GUILayout.Button("\nSet Tags And Reassign Materials If Needed\n"))
  508. {
  509. Undo.RegisterCompleteObjectUndo(notTageddMat.Keys.ToArray(), "InTerra Set Tags for Material(s)");
  510. foreach (Material mat in notTageddMat.Keys)
  511. {
  512. mat.SetOverrideTag("BaseName", baseName);
  513. mat.SetOverrideTag("TerrainName", notTageddMat[mat].name);
  514. }
  515. InTerra_MaterialManager.CreateRelatedMaterialsList(baseName, relatedMaterials);
  516. InTerra_MaterialManager.ReassignMaterials(baseName, relatedMaterials, allRendTerrain);
  517. CreateNewMatList();
  518. notTageddMat.Clear();
  519. setedTags = true;
  520. Material newSelected = Selection.activeGameObject.GetComponent<Renderer>().sharedMaterial;
  521. if (newSelected != null)
  522. {
  523. SelectedMaterial = newSelected;
  524. }
  525. else
  526. {
  527. Close();
  528. }
  529. }
  530. }
  531. static string DirectoryPath(Material mat)
  532. {
  533. string assetPath = AssetDatabase.GetAssetPath(mat);
  534. string directoryPath = "";
  535. if (assetPath.Length > 0)
  536. {
  537. directoryPath = Path.GetDirectoryName(assetPath);
  538. directoryPath = directoryPath.Replace("\\", "/");
  539. }
  540. return directoryPath;
  541. }
  542. static string TagsName(Material mat)
  543. {
  544. string tagName = mat.GetTag("BaseName", false) + "_" + mat.GetTag("TerrainName", false);
  545. return tagName;
  546. }
  547. }
  548. }