In large-scale projects, many scripts, many sub-objects, want to find their own script to hang where, especially just take over other people's projects, this is a headache. Below a small feature to make it easy for everyone to use. The script is not complicated, but it's convenient.
Note: The following two scripts need to be placed under editor = Tools
usingUnityeditor;usingUnityengine; Public classfindmissingscriptsrecursively:editorwindow{Static intGo_count =0, Components_count =0, Missing_count =0; [MenuItem ("window/findmissingscriptsrecursively")] Public Static voidShowWindow () {Editorwindow.getwindow (typeof(findmissingscriptsrecursively)); } Public voidOngui () {if(Guilayout.button ("Find Missing Scripts in selected Gameobjects") ) {findinselected (); } } Private Static voidfindinselected () {gameobject[] go=selection.gameobjects; Go_count=0; Components_count=0; Missing_count=0; foreach(Gameobject Ginchgo) {Findingo (g); } Debug.Log (string. Format ("searched {0} gameobjects, {1} components, found {2} missing", Go_count, Components_count, Missing_count)); } Private Static voidFindingo (Gameobject g) {Go_count++; Component[] Components= g.getcomponents<component>(); for(inti =0; I < components. Length; i++) {Components_count++; if(Components[i] = =NULL) {Missing_count++; strings =G.name; Transform T=G.transform; while(T.parent! =NULL) {s= T.parent.name +"/"+s; T=t.parent; } Debug.Log (S+"Has a empty script attached in position:"+I, g); } } //Now recurse through all child GO (if there is any): foreach(Transform Childtinchg.transform) {//Debug.Log ("searching" + Childt.name + ""); Findingo (Childt.gameobject); } }}
usingUnityeditor;usingUnityengine;usingSystem.Collections;usingSystem.Collections.Generic;///////////////////////////////////////////////////////////////////////////// //find the specified script component in the node and all child nodes///////////////////////////////////////////////////////////////////////////// Public classmonofinder:editorwindow{Transform Root=NULL; Monoscript Scriptobj=NULL; intLoopcount =0; List<Transform> results =NewList<transform>(); [MenuItem ("Level4/finder/monofinder")] Static voidInit () {Editorwindow.getwindow (typeof(Monofinder)); } voidOngui () {Guilayout.label ("node:"); Root= (Transform) Editorguilayout.objectfield (Root,typeof(Transform),true); Guilayout.label ("Script Type:"); Scriptobj= (monoscript) Editorguilayout.objectfield (Scriptobj,typeof(Monoscript),true); if(Guilayout.button ("Find") {results. Clear (); Loopcount=0; Debug.Log ("start the search."); Findscript (root); } if(Results. Count >0) { foreach(Transform tinchresults) {Editorguilayout.objectfield (T,typeof(Transform),false); } } Else{Guilayout.label ("No Data"); } } voidfindscript (Transform root) {if(Root! =NULL&& Scriptobj! =NULL) {Loopcount++; Debug.Log (".."+ Loopcount +":"+root.gameObject.name); if(Root. Getcomponent (Scriptobj.getclass ())! =NULL) {results. ADD (root); } foreach(Transform tinchroot) {findscript (t); } } }}
Unity Custom Compiler Window Lookup script