Unity3D开发之查找面板上某个脚本(包括Missing)
原地址:http://blog.csdn.net/lihandsome/article/details/24265411
有时候我们需要知道某个脚本在场景上面哪里用到,或者那个脚本被删除了但又没有把相关游戏场景的关联东西删掉,那样我们就要一个脚本来查找一下了:
PS:下面两个脚本都要放到assets/Editor下面哦。。
查找missing的脚本:
- using UnityEngine;
- using UnityEditor;
- public class FindMissingScriptsRecursively : EditorWindow
- {
- static int go_count = 0, components_count = 0, missing_count = 0;
- [MenuItem("Window/FindMissingScriptsRecursively")]
- public static void ShowWindow()
- {
- EditorWindow.GetWindow(typeof(FindMissingScriptsRecursively));
- }
- public void OnGUI()
- {
- if (GUILayout.Button("Find Missing Scripts in selected GameObjects"))
- {
- FindInSelected();
- }
- }
- private static void FindInSelected()
- {
- GameObject[] go = Selection.gameObjects;
- go_count = 0;
- components_count = 0;
- missing_count = 0;
- foreach (GameObject g in go)
- {
- FindInGO(g);
- }
- Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count));
- }
- private static void FindInGO(GameObject g)
- {
- go_count++;
- Component[] components = g.GetComponents<Component>();
- for (int i = 0; i < components.Length; i++)
- {
- components_count++;
- if (components[i] == null)
- {
- missing_count++;
- string s = g.name;
- Transform t = g.transform;
- while (t.parent != null)
- {
- s = t.parent.name +"/"+s;
- t = t.parent;
- }
- Debug.Log (s + " has an empty script attached in position: " + i, g);
- }
- }
- // Now recurse through each child GO (if there are any):
- foreach (Transform childT in g.transform)
- {
- //Debug.Log("Searching " + childT.name + " " );
- FindInGO(childT.gameObject);
- }
- }
- }
查找某个脚本的脚本:
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- /////////////////////////////////////////////////////////////////////////////
- //查找节点及所有子节点中,是否有指定的脚本组件
- /////////////////////////////////////////////////////////////////////////////
- public class MonoFinder : EditorWindow {
- Transform root = null;
- MonoScript scriptObj = null;
- int loopCount = 0;
- List<Transform> results = new List<Transform>();
- [MenuItem("Level4/Finder/MonoFinder")]
- static void Init(){
- EditorWindow.GetWindow(typeof(MonoFinder));
- }
- void OnGUI(){
- GUILayout.Label("节点:");
- root = (Transform)EditorGUILayout.ObjectField(root,typeof(Transform),true);
- GUILayout.Label("脚本类型:");
- scriptObj = (MonoScript)EditorGUILayout.ObjectField(scriptObj,typeof(MonoScript),true);
- if(GUILayout.Button("Find")){
- results.Clear();
- loopCount = 0;
- Debug.Log("开始查找.");
- FindScript(root);
- }
- if(results.Count > 0){
- foreach(Transform t in results){
- EditorGUILayout.ObjectField(t,typeof(Transform),false);
- }
- }else{
- GUILayout.Label("无数据");
- }
- }
- void FindScript(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 t in root){
- FindScript(t);
- }
- }
- }
- }
相关的链接:
http://wiki.unity3d.com/index.php?title=FindMissingScripts
http://superherosk123.iteye.com/blog/1632627
Unity3D开发之查找面板上某个脚本(包括Missing)的更多相关文章
- Unity3D开发之查找面板上某个脚本(包含Missing)
有时候我们须要知道某个脚本在场景上面哪里用到,或者那个脚本被删除了但又没有把相关游戏场景的关联东西删掉,那样我们就要一个脚本来查找一下了: PS:以下两个脚本都要放到assets/Editor以下哦. ...
- 出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码)
出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码) 购买后可提供相应的小修改,以及教你使用往这个多列面里再加上按钮功能! 这套源码可作为工作使用,也可用为新手学习AI脚面 ...
- 跟我从零基础学习Unity3D开发--NGUI入门基础
英雄联盟(撸啊撸) QQ飞车 魔兽世界等等相信大家都玩过游戏吧,玩过那UI知道是什么吧?UI可能说得有点专业的话那么游戏中那些属性面板例如: 现在对UI有一定认识了吧!回想一下您玩过的游戏就一定知道什 ...
- ADO面板上的控件简介
ADO面板上的控件简介 一. TADOConnection组件该组件用于建立数据库的连接.ADO的数据源组件和命令组件可以通过该组件运行命令及数据库中提取数据等.该组件用于建立数据库的连接,该连接可被 ...
- Delphi7 ADO面板上的控件简介
? ADO Connection的主要方法:1) Begin Trans 开始启动一个新的事务,必须保证数据连接处于激活状态.2) Cancel 关闭于数据库的连接.3) Commit T ...
- 添加启动游戏过渡场景Default Splash Scene(Unity3D开发之十三)
添加启动游戏过渡场景Default Splash Scene(Unity3D开发之十三) 猴子原创,欢迎转载.转载请注明: 转载自Cocos2Der-CSDN,谢谢! 原文地址: http://blo ...
- IE8“开发人员工具”(上)
认识“开发人员工具” 开发人员工具在IE8的工具菜单下,或者直接点击F12快捷键也可以呼叫出来. 提供一系列的小工具,让你可以方便的查找页面的bug,包括html代码.css代码和JavaScript ...
- unity3d开发实战《啪啪三国》技术详解!
去年11月,上海火溶网络CEO王伟峰以其第一款3d手游产品<啪啪三国>为例,着重讲解了unity3D手机网游开发的经验,其中涉及了团队组成.人员要求.常见的unity3d开发遇到的坑及解 ...
- 菜鸟在线教你用Unity3D开发VR版的Hello World
大家好,我是菜鸟在线的小编.这篇短文将告诉大家如何用Unity3D开发VR版的Hello World. 1开启SteamVR并连接Vive设备 (a)登录Steam客户端,并点击右上角的VR按钮,这时 ...
随机推荐
- SQL Server 错误行号
https://msdn.microsoft.com/zh-cn/library/ms178600.aspx 返回发生错误的行号,该错误导致运行 TRY…CATCH 构造的 CATCH 块. 语法 E ...
- 使用ptrace向已运行进程中注入.so并执行相关函数
这个总结的很好,从前一个项目也用到这中技术 转自:http://blog.csdn.net/myarrow/article/details/9630377 1. 简介 使用ptrace向已运行进程中注 ...
- Cocos2d-x中SQLite数据库管理工具
数据库创建完成后,我们可能需要看看数据库中数据是否成功插入,很多人喜欢使用图形界面工具来管理SQLite数据库.SQLite图形界面管理工具有很多,我推荐使用SQLiteStudio工具,下载地址ht ...
- Cocos2d-x内置粒子系统
从类图中我们可以看到,Cocos2d-x中有内置的11粒子,这些粒子的属性都是预先定义好的,我们也可以在程序代码中单独修改某些属性,我们在上一节的实例中都已经实现了这些属性的设置. 内置粒子系统 内置 ...
- C# WinForm TextBox添加水印效果
1.新建项目添加WatermarkTextBox类: using System; using System.Collections.Generic; using System.Text; using ...
- ASP.NET MVC 路由进阶(之二)--自定义路由约束
3.自定义路由约束 什么叫自定义路由约束呢?假如路由格式为archive/{year}/{month}/{day},其中year,month,day是有约束条件的,必须是数字,而且有一定范围. 这时候 ...
- EL表达式获取Map和List中的值
EL表达式获取Map和List中的值 EL表达式取Map中的值: 当Map中是String,String时 后台servlet中: Map<String, String> map1 = ...
- lex&yacc4
yacc: we cannt use the $$ value dirictly. we need get it irrotly;
- KMeans聚类算法Hadoop实现
Assistance.java 辅助类,功能详见注释 package KMeans; import org.apache.hadoop.conf.Configuration; import org. ...
- Windows7旗舰版32激活码 OEM密钥
1.win7旗舰版32激活码如下: KH2J9-PC326-T44D4-39H6V-TVPBY TFP9Y-VCY3P-VVH3T-8XXCC-MF4YK 236TW-X778T-8MV9F-937G ...