当前位置:网站首页>【Unity编辑器扩展实践】、查找所有引用该图片的预制体
【Unity编辑器扩展实践】、查找所有引用该图片的预制体
2022-06-28 12:00:00 【Unique_849997563】
上一篇Unity编辑器扩展实践二、通过代码查找所有预制中已经查到到所有的预制体了。
然后我们就可以用这些预制体做一些其他的操作了,比如查找该预制的资源引用。可以直接遍历预制,找到预制里面的所有Image组件,然后比较Sprite属性的值,看是否和检测的资源相同。
Prefabs.Clear();
if (m_sprite == null) return;
EditorUtility.DisplayCancelableProgressBar("查找图集", "查找图集中...", 0);
List<Image> aorImages;
List<GameObject> _prefabList = GetAllPrefabByAssetDatabase("Assets/Resources/TSUprefabs");
for (int i = 0; i < _prefabList.Count; i++)
{
if (_prefabList[i] == null)
{
continue;
}
aorImages = new List<Image>(_prefabList[i].GetComponentsInChildren<Image>());
if (aorImages == null|| aorImages.Count<=0)
{
continue;
}
foreach (var image in aorImages)
{
if (image.sprite==null)
{
continue;
}
if (image.sprite.Equals(m_sprite))
{
Prefabs.Add(_prefabList[i]);
break;
}
}
bool _cancel = EditorUtility.DisplayCancelableProgressBar("查找图集", "查找图集中("+i+"/"+ (float)_prefabList.Count+"...", i / (float)_prefabList.Count);
if (_cancel)
{
break;
}
}
EditorUtility.ClearProgressBar();同理可以用这个方法给想要的预制体替换图片,只需要找到对应的预制组件,将图片复制给Image组件即可。
查找图片的引用可以用这个方法,其他资源同理。
边栏推荐
- Simple understanding of ThreadLocal
- Daily practice of C language - day 3: calculate the number of occurrences of sub strings of strings
- AcWing 607. Average 2 (implemented in C language)
- 【C语言】如何很好的实现复数类型
- Dongyuhui, New Oriental and Phoenix Satellite TV
- Connectionreseterror: [winerror 10054] the remote host forced an existing connection to be closed
- 多维度监控:智能监控的数据基础
- 开源项目维权成功案例: spug 开源运维平台成功维权
- Using MySQL database in the express framework of node
- The development and principle of the metacosmic system
猜你喜欢

In less than an hour, apple destroyed 15 startups

RemoteViews的作用及原理

Chendanqi, Fang Fei, guquanquan and Li Bo won the prize, and the list of Sloan research award in 2022 was released

Remoteviews layout and type restriction source code analysis
![[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination](/img/06/df5a64441814c9ecfa2f039318496e.jpg)
[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination

【北京航空航天大学】考研初试复试资料分享

水果FL Studio/Cubase/Studio one音乐宿主软件对比

2018 joint examination of nine provinces & Merging of line segment trees

Django -- MySQL database reflects the mapping data model to models

Day32 JS note event (Part 1) September 27, 2021
随机推荐
【JS】斐波那契数列实现(递归与循环)
来吧元宇宙,果然这热度一时半会儿过不去了
【vi/vim】基本使用及命令汇总
Web3安全连载(3) | 深入揭秘NFT钓鱼流程及防范技巧
[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination
Chapter 2 do you remember the point, line and surface (2)
Dongyuhui, New Oriental and Phoenix Satellite TV
day25 js中的预解析、递归函数、事件 2021.09.16
如何获取泛型的类型
What method is required for word, PDF and txt files to realize full-text content retrieval?
【北京航空航天大学】考研初试复试资料分享
【C语言】判断三角形
Map sorting tool class
AcWing 608. Poor (implemented in C language)
cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?
Zero basic C language (I)
不到一小时,苹果摧毁了15家初创公司
纯纯大怨种!那些年被劝退的考研专业
什么是数据合规?怎样做到数据合规?
Excel import / export convenience tool class