当前位置:网站首页>【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组件即可。
查找图片的引用可以用这个方法,其他资源同理。
边栏推荐
- 如何获取泛型的类型
- AcWing 606. Average 1 (implemented in C language)
- Open3d manual clipping point cloud
- 3. seat number
- .NET混合开发解决方案24 WebView2对比CefSharp的超强优势
- SoapUI rookie tutorial
- Is there a threshold for opening futures accounts? How to open futures accounts safely on the Internet
- AcWing 608. Poor (implemented in C language)
- Custom title bar view
- Redis 原理 - List
猜你喜欢

Day33 JS note event (Part 2) September 28, 2021

JS foundation 8

不到一小时,苹果摧毁了15家初创公司

Simple understanding of ThreadLocal

开源项目维权成功案例: spug 开源运维平台成功维权

Using soapUI to obtain freemaker's FTL file template

Multi dimensional monitoring: the data base of intelligent monitoring

携手Cigent:群联为SSD主控固件引入高级网络安全防护特性

SEO优化的许多好处是与流量有直接关系

Array method in JS 2021.09.18
随机推荐
3. seat number
Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
Django -- MySQL database reflects the mapping data model to models
Deployment and optimization of vsftpd service
RemoteViews布局和类型限制源码分析
Prefix and (2D)
Three ways to implement LRU cache (recommended Collection)
案例驱动 :从入门到掌握Shell编程详细指南
JNI confusion of Android Application Security
Packaging and publishing application of jetpack compose desktop version
Redis 原理 - List
【C语言】结构体嵌套二级指针的使用
Chapter 2 do you remember the point, line and surface (2)
Usage and principle of precomputedtextcompat
【C语言】二叉树的实现及三种遍历
2. single digit statistics
Privilege management of vivo mobile phone
day25 js中的预解析、递归函数、事件 2021.09.16
Many benefits of SEO optimization are directly related to traffic
AcWing 610. Salary and bonus (implemented in C language)