(Unity)Editorの拡張:特定のTagの付いたオブジェクトを探す

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ★追加
using UnityEditor;

public class TagSearch : EditorWindow // ★変更
{
    public string tagName = "";
    public List<GameObject> results;
    private Vector2 resultsList;

    // 上部のバーに表示される
    [MenuItem("TagTool/TagSearch")]
    static void Init()
    {
        TagSearch window = EditorWindow.GetWindow<TagSearch>("TagSearchX");

        window.ShowPopup();
    }

    // 実際の処理を記載する
    private void OnGUI()
    {
        EditorGUILayout.BeginVertical(); // 垂直配置(縦配置)の開始
        {
            // タイトルラベルの作成(名前 + 太文字スタイル)
            EditorGUILayout.LabelField("検索設定", EditorStyles.boldLabel);
            {
                GUILayout.BeginHorizontal(); // 水平配置(横配置)の開始

                // 下記2つの要素が水平に配置される。
                EditorGUILayout.LabelField("Tag : ", GUILayout.MaxWidth(50));
                tagName = EditorGUILayout.TagField(tagName);

                GUILayout.EndHorizontal(); // 水平配置(横配置)の終了

                if(GUILayout.Button("Find"))
                {
                    Find();
                }
            }

            EditorGUILayout.LabelField("結果", EditorStyles.boldLabel);
            {
                if(results != null)
                {
                    // 該当のオブジェクトが何個存在するか表示
                    EditorGUILayout.LabelField("該当:", results.Count.ToString() + "個", EditorStyles.boldLabel);

                    resultsList = EditorGUILayout.BeginScrollView(resultsList);
                    {
                        // 該当オブジェクトの一覧を表示
                        foreach (GameObject r in results)
                        {
                            EditorGUILayout.ObjectField(r, typeof(GameObject), false);
                        }
                    }

                    EditorGUILayout.EndScrollView();
                }
            }
        }
        EditorGUILayout.EndVertical(); // 垂直配置(縦配置)の終了
    }

    void Find()
    {
        if(tagName != null && tagName != "")
        {
            results = new List<GameObject>(GameObject.FindGameObjectsWithTag(tagName));
        }
    }
}

(実行結果)