[MenuItem("Edit/Cleanup Missing Scripts")]
static void CleanupMissingScripts ()
{
for(int i = ; i < Selection.gameObjects.Length; i++)
{
var gameObject = Selection.gameObjects[i]; // We must use the GetComponents array to actually detect missing components
var components = gameObject.GetComponents<Component>(); // Create a serialized object so that we can edit the component list
var serializedObject = new SerializedObject(gameObject);
// Find the component list property
var prop = serializedObject.FindProperty("m_Component"); // Track how many components we've removed
int r = ; // Iterate over all components
for(int j = ; j < components.Length; j++)
{
// Check if the ref is null
if(components[j] == null)
{
// If so, remove from the serialized component array
prop.DeleteArrayElementAtIndex(j-r);
// Increment removed count
r++;
}
} // Apply our changes to the game object
serializedObject.ApplyModifiedProperties();
}
}

原文链接:http://blog.csdn.net/zzmkljd/article/details/52840724

参考链接:

http://www.tallior.com/find-missing-references-unity/

https://github.com/liortal53/MissingReferencesUnity

Unity用代码实现Remove Missing Script的更多相关文章

  1. npm ERR! missing script: dev 报错解决

    npm run dev 报错:missing script:dev 今天在运行Vue项目时,在运行npm  run dev时报错如下图: 打开package.js文件夹,发现文件夹里的scripts有 ...

  2. npm ERR! missing script: build

    webpack-bundle-analyzer webpack可视化插件,用来查看一共打了多少个包,每个包的体积和包里面的情况. 启动查看 npm run build --report 结果报错npm ...

  3. 运行npm start vue.js项目 出现 npm ERR! missing script: start 错误

    npm ERR! missing script: start 错误 有可能缺少依赖包,运行nmp install安装依赖(一般都依赖很多包,过程有点慢),安装完后发现多一个 node_modules文 ...

  4. npm ERR! missing script: dev 解决方案

    运行命令npm run dev 出现     npm ERR! missing script: dev  的错误 这是因为vue 版本问题,使用 npm run serve 来运行项目

  5. Unity实现代码控制音频播放

    前言 很久没说过Unity了,现在说一下Unity用代码控制音频播放 准备工作 1.需要播放的音频 2.给需要加声音的对象加Audio Source组件 3.新建Play脚本,并绑定需要播放声音的对象 ...

  6. unity对话代码

    这个是根据网上unity GUI打字机教程修改的 原教程是JS,我给改成了C#,然后增加了许多功能 这个教程能实现一段文字对话,有打字机显示效果,能写许多对话,能快进对话,总之现在RPG游戏里有的功能 ...

  7. 微软IOC容器Unity简单代码示例3-基于约定的自动注册机制

    @(编程) [TOC] Unity在3.0之后,支持基于约定的自动注册机制Registration By Convention,本文简单介绍如何配置. 1. 通过Nuget下载Unity 版本号如下: ...

  8. 微软IOC容器Unity简单代码示例2-配置文件方式

    @(编程) 1. 通过Nuget下载Unity 这个就不介绍了 2. 接口代码 namespace UnityDemo { interface ILogIn { void Login(); } } n ...

  9. 微软IOC容器Unity简单代码示例1

    @(编程) 1. 通过Nuget下载Unity 这个就不介绍了 2. 接口代码 namespace UnityDemo { interface ILogIn { void Login(); } } 3 ...

随机推荐

  1. quartz定时任务框架的使用以及原理

    quartz定时任务时间设置 这些星号由左到右按顺序代表 :     *    *     *     *    *     *   *                                 ...

  2. mongo源码学习(四)服务入口点ServiceEntryPoint

    在上一篇博客mongo源码学习(三)请求接收传输层中,稍微分析了一下TransportLayer的作用,这篇来看下ServiceEntryPoint是怎么做的. 首先ServiceEntryPoint ...

  3. SQL 增删改查

    create table [表名]([自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,[字段1] nVarChar(50) default \'默认值\' null , ...

  4. android 中遇到 imageView getWidth 始终为0 时 ,设置 setImageBitmap 的方法

    先说说我的遇到的问题: 1. 我在activity里写一个 fragment 2.这个fragment里有个 imageView ,用于显示图片. 我使用 asyncTask获得图片,并准备在这个im ...

  5. js 获取页面宽度

    特例: 当$(window).width()无效时 /* 出现时机: iframe内嵌子页面在加载过程中取不到$(window).width(),非必现,机率大概1 / 20 */ 可用以下方式获取屏 ...

  6. substance新版及问题

    新版地址:https://github.com/Insubstantial,目前是7.3版 http://stackoverflow.com/questions/3657538/substance-u ...

  7. 获取checkbox的选中的值

    var arr = new Array(); var idsObj = $("input [name='ids']"); for(var i=0;i<idsObj.lengt ...

  8. add new row to data.frame/dataframe

    df<-NULL new_row<-data.frame(colA="xxx",colB=123) df<-rbind(df,new_row)

  9. [hbase] 查询数据

    获取hbase数据 说说:count 'SOCIA:T_SOCIA_ALBUM_TALK'scan 'SOCIA:T_SOCIA_ALBUM_TALK',{LIMIT=>5}get 'SOCIA ...

  10. [kafka] 001_kafka起步

    一.简介 Kafka is a distributed, partitioned, replicated commit log service. It provides the functionali ...