Unity Custom Compiler Window Lookup script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.