Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- public class ExampleEditor : EditorWindow {
- GameObject[] myObjects;
- [MenuItem ("Window/My Window")]
- static void Init () {
- ExampleEditor window = (ExampleEditor)EditorWindow.GetWindow (typeof (ExampleEditor));
- window.Show();
- }
- void OnEnable() {
- LoadObjects ();
- }
- void LoadObjects() {
- GameObject[] allObjs = Resources.FindObjectsOfTypeAll<GameObject> ();
- List<GameObject> objsWithTag = new List<GameObject> ();
- foreach (GameObject o in allObjs) {
- if (o.tag == "myTag") {
- objsWithTag.Add (o);
- Debug.Log ("Add: " + o.name);
- }
- }
- myObjects = objsWithTag.ToArray ();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement