Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Text.RegularExpressions;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UIElements;
- public class EditRename : EditorWindow
- {
- [MenuItem("dev/hierarchly")]
- public static void showHierEditWind()
- {
- EditRename hierWind = GetWindow<EditRename>();
- hierWind.titleContent = new GUIContent("rename tiles");
- }
- public TextField newTagTitle;
- public void CreateGUI()
- {
- VisualElement rootVisual = rootVisualElement;
- Button mainBtn = new Button();
- mainBtn.name = "renameBtn";
- mainBtn.text = "rename tiles";
- mainBtn.clicked += MainBtn_clicked;
- rootVisual.Add(mainBtn);
- Button changeTagBtn = new Button();
- changeTagBtn.name = "changeTagBtn";
- changeTagBtn.text = "change tag";
- changeTagBtn.clicked += ChangeTagBtn_clicked;;
- newTagTitle = new TextField();
- newTagTitle.value = "set title new tag";
- rootVisual.Add(newTagTitle);
- rootVisual.Add(changeTagBtn);
- }
- private void MainBtn_clicked()
- {
- GameObject[] objs = GameObject.FindGameObjectsWithTag("tile");
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- {
- objs[(i * 10) + j].name = string.Format("tile {0} {1}", i, j);
- }
- }
- }
- private void ChangeTagBtn_clicked()
- {
- GameObject[] objs = GameObject.FindGameObjectsWithTag("tile");
- foreach (GameObject obj in objs)
- obj.transform.GetChild(0).tag = newTagTitle.value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement