Recently, some optimization tools have been made to extract the mouse-picking function separately.
Can traverse all selected types of resources, recursively folders
Can compile a component of all prefab, which is also recursive
Using unityengine;using system.collections;using unityeditor;using system.collections.generic;using System.componentmodel;using Object = unityengine.object;//Find public static class Enumselection {//Enumerate all resources of type T in the selected resource public static ienumerable<t> enumincurrentselection<t> () where t:object{object[] Selectionasset = Selection.getfiltered (typeof (Object), selectionmode.deepassets), foreach (Var s in selectionasset) {var temp = s as t;if (n Ull! = temp) {yield return temp;}} Yield break;} Enumerates all the gameobject types of resources public static ienumerable<gameobject> enumgameobjectincurrentselection () {foreach (var s) In Enumincurrentselection<gameobject> ()) {yield return s;} Yield break;} Recursively enumerates all gameobjectpublic static ienumerable<gameobject> enumgameobjectrecursiveincurrentselection () {foreach (Var s in enumincurrentselection<gameobject> ()) {foreach (var g in enumgameobjectrecursive (s)) {yield return g;}}} public static ienumerable<gameobject> enumgameobjectrecursive (Gameobject gO) {yield return go;for (int i=0; i<go.transform.childcount; i++) {foreach (Var t in Enumgameobjectrecursive ( Go.transform.GetChild (i). Gameobject) {yield return t;}}} Recursively enumerates all compoentpublic static ienumerable<t> enumcomponentrecursiveincurrentselection<t> () where T: Unityengine.component{foreach (Var go in enumincurrentselection<gameobject> ()) {foreach (var c in go.) Getcomponentsinchildren<t> (True)) {yield return C;}}}
Unity3d Mouse picking small function collection