Unity3d 鼠标拣选小功能集合
最近在做一些优化工具,把鼠标拣选的功能单独抽出来。
可遍历所有选中的某类型资源,会递归文件夹
可编译所有prefab的某个Component,也是递归的
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Collections.Generic;
using System.ComponentModel;
using Object = UnityEngine.Object; //在选中的资源中查找
public static class EnumSelection { //枚举所有的T类型的资源
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 (null != temp)
{
yield return temp;
}
} yield break;
} //枚举所有的GameObject类型的资源
public static IEnumerable<GameObject> EnumGameObjectInCurrentSelection()
{
foreach (var s in EnumInCurrentSelection<GameObject>())
{
yield return s;
} yield break;
} //递归枚举所有GameObject
public 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;
}
}
} //递归枚举所有Compoent
public 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 鼠标拣选小功能集合的更多相关文章
- JavaScript 常用的小功能集合
1. 得到当前用户使用的浏览器的内核版本 function getExplorer(){ var browser = ""; var explorer = window.navig ...
- VBA小功能集合-判断列内是否有重复值
1.判断列内是否有重复值: Dim arrT As Range Dim rng As Range Set arrT = Range("A:A")'判读A列单元格 For Each ...
- Visual Studio Debugger中七个鲜为人知的小功能
Visual Studio debugger是一个很棒的调试工具,可以帮助程序猿们快速地发现和解决问题.这里给大家简单介绍一下VS调试工具中的七个鲜为人知的小功能. 1. 一键跳转到指定语句 调 ...
- C#、Java中的一些小功能点总结(持续更新......)
前言:在项目中,有时候一些小的功能点,总是容易让人忽略,但是这些功能加在项目中往往十分的有用,因此笔者在这里总结项目中遇到的一些实用的小功能点,以备用,并持续更新...... 1.禁用DataGrid ...
- Unity3D事件顺序与功能
Unity3D中所有控制脚本的基类MonoBehaviour有一些虚函数用于绘制中事件的回调,也可以直接理解为事件函数,例如大家都很清楚的Start,Update等函数,以下做个总结. Awake 当 ...
- Laravel实用小功能
Laravel实用小功能 1.控制访问次数 laravel5.2的新特性,通过中间件设置throttle根据IP控制访问次数 原理:通过回传三个响应头X-RateLimit-Limit,X-RateL ...
- js小功能整理
/** * 判断是否包含字符串某字符串 * @param {[type]} str [被检测的字符串] * @param {[type]} substr [检测是否含有的字符串] * @return ...
- iOS--知识综合应用成就时髦小功能点
iOS--知识综合应用成就时髦小功能点
- [Unity3D]做个小Demo学习Input.touches
[Unity3D]做个小Demo学习Input.touches 学不如做,下面用一个简单的Demo展示的Input.touches各项字段,有图有真相. 本项目已发布到Github,地址在(https ...
随机推荐
- Linux查看软件安装路径
Linux中查看某 个软件的安装路径(地址)有时显得非常重要.比如某个文件的快速启动项被删除,或者你要建立快速启动项,或者想删除. 添加安装文件等等,很多地方都要用到查案文件安装路径的命令. 这里给大 ...
- 代码中access 的使用
C++代码:if(access(strZip.c_str(), 0) == 0){...} 此处为判断strZip中文件是否存在 .c_str() 是他自身字符串名称,该名称是一个压缩文件 ...
- fedora配置网络
网络配置包括3个部分: ipadd的配置 gateway profile dns profile 格式区别: 1和2的格式都是: CONFIG_ITEM = value; 3的格式是: nameser ...
- 只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs
只有文本编辑器才是王道, 什么ide都是evil的浮云, 看看linus linux的内核开发工具vim emacs [ide is evil] (http://i.cnblogs.com/EditP ...
- netstat miscellaneousness
netstat -a (--all) : show both listening and non-listening sockets 默认是不显示正在侦听的进程,只显示已经established的 n ...
- linux下如何查看chm文件
转自:http://www.cnblogs.com/jesseZh/p/4036811.html (64位) sudo dpkg -i chmsee_1.3.0-2ubuntu2_amd64.d ...
- hdu3555 Bomb (记忆化搜索 数位DP)
http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Memory ...
- oracle 中的Ipad()函数
本文基于转载: lpad函数从左边对字符串使用指定的字符进行填充.lpad意思是从左边填充的意思. 语法格式如下: lpad( string, padded_length, [ pad_string ...
- 《深入浅出WPF》笔记二
1.消息驱动与事件驱动 事件 即封装过的消息 2.数据驱动 3.Binding Source.Target.Path.INotifyPropertyChanged结构 this.textBoxName ...
- plink远程连接服务器进行编译
脚本命令: echo y|D:\remote_link\plink -l user -pw password 172.16.0.101 "export LANG=en_US;cd / ...