最近在做一些优化工具,把鼠标拣选的功能单独抽出来。

可遍历所有选中的某类型资源,会递归文件夹

可编译所有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 鼠标拣选小功能集合的更多相关文章

  1. JavaScript 常用的小功能集合

    1. 得到当前用户使用的浏览器的内核版本 function getExplorer(){ var browser = ""; var explorer = window.navig ...

  2. VBA小功能集合-判断列内是否有重复值

    1.判断列内是否有重复值: Dim arrT As Range Dim rng As Range Set arrT = Range("A:A")'判读A列单元格 For Each ...

  3. Visual Studio Debugger中七个鲜为人知的小功能

    Visual Studio debugger是一个很棒的调试工具,可以帮助程序猿们快速地发现和解决问题.这里给大家简单介绍一下VS调试工具中的七个鲜为人知的小功能. 1.    一键跳转到指定语句 调 ...

  4. C#、Java中的一些小功能点总结(持续更新......)

    前言:在项目中,有时候一些小的功能点,总是容易让人忽略,但是这些功能加在项目中往往十分的有用,因此笔者在这里总结项目中遇到的一些实用的小功能点,以备用,并持续更新...... 1.禁用DataGrid ...

  5. Unity3D事件顺序与功能

    Unity3D中所有控制脚本的基类MonoBehaviour有一些虚函数用于绘制中事件的回调,也可以直接理解为事件函数,例如大家都很清楚的Start,Update等函数,以下做个总结. Awake 当 ...

  6. Laravel实用小功能

    Laravel实用小功能 1.控制访问次数 laravel5.2的新特性,通过中间件设置throttle根据IP控制访问次数 原理:通过回传三个响应头X-RateLimit-Limit,X-RateL ...

  7. js小功能整理

    /** * 判断是否包含字符串某字符串 * @param {[type]} str [被检测的字符串] * @param {[type]} substr [检测是否含有的字符串] * @return ...

  8. iOS--知识综合应用成就时髦小功能点

    iOS--知识综合应用成就时髦小功能点

  9. [Unity3D]做个小Demo学习Input.touches

    [Unity3D]做个小Demo学习Input.touches 学不如做,下面用一个简单的Demo展示的Input.touches各项字段,有图有真相. 本项目已发布到Github,地址在(https ...

随机推荐

  1. pch

    #define kWeakSelf(weakSelf) __weak __typeof(self)weakSelf = self; #ifndef __OPTIMIZE__#define NSLog( ...

  2. [IOC]Unity使用

    Unity是什么? unity是patterns&practices团队开发的一个轻量级.可扩展的依赖注入容器. Unity特性 1.它提供了创建(或者装配)对象实例的机制,而这些对象实例可能 ...

  3. 全屏背景:15个jQuery插件实现全屏背景图像或媒体

    动态网站通常利用背景图像或预加载屏幕,以保证所有资源都加载到页面上,在浏览器中充分呈现.现在很多网站都炫耀自己的图像作为背景图像全屏背景,追溯到旧的Flash网站却用自己的方式在HTML资源重布局. ...

  4. app的meta

    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> < ...

  5. Codeforces Round #270 1002

    Codeforces Round #270 1002 B. Design Tutorial: Learn from Life time limit per test 1 second memory l ...

  6. Hadoop之Storm安装

    nimbus:主节点,负责分发代码,分配任务(只能有一个)supervisor:从节点,负责执行任务(可以有多个) jdkzookeeper(192.168.1.170/171/172)建议在zook ...

  7. jQuery - 动态创建iframe并加载页面

    <html> <head> <script language="JavaScript" src="jquery-1.11.1.min.js& ...

  8. C++中的内联成员函数与非内联成员函数

    在C++中内联成员函数与非内联成员函数的可以分为两种情况: 1.如果成员函数的声明和定义是在一起的,那么无论有没有写inline这个成员函数都是内联的,如下: using namespace std; ...

  9. JQuery测手速小游戏-遁地龙卷风

    (-1)写在前面 我用的chrome49,jquery3.0,我得到过399分,信不信由你. (1)设计思路 两个p元素放在div里,每个p元素的高度和宽度都和div一样,当鼠标放在div上时,第一个 ...

  10. ajax验证登录注册

    <form id="form1" onsubmit="return false;"> <table id="login-table& ...