当前位置:网站首页>[unity Editor Extension practice] find all prefabs referencing this picture
[unity Editor Extension practice] find all prefabs referencing this picture
2022-06-28 12:22:00 【Unique_ eight hundred and forty-nine million nine hundred and n】
Last one Unity Editor Extension practice 2 、 Find all prefabrications through code All the prefabricated bodies have been found in .
Then we can use these prefabricated bodies to do some other operations , For example, find the resource reference of the prefabrication . You can traverse the prefabrication directly , Find everything in the prefab Image Components , Then compare Sprite The value of the property , See if it is the same as the detected resources .
Prefabs.Clear();
if (m_sprite == null) return;
EditorUtility.DisplayCancelableProgressBar(" Find Atlas ", " Find a graph set ...", 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(" Find Atlas ", " Find a graph set ("+i+"/"+ (float)_prefabList.Count+"...", i / (float)_prefabList.Count);
if (_cancel)
{
break;
}
}
EditorUtility.ClearProgressBar();
Similarly, you can use this method to replace the picture for the desired preform , Just find the corresponding prefabricated components , Copy picture to Image Components .
To find a reference to an image, use this method , The same is true for other resources .
边栏推荐
- [source code + code comments] error state Kalman filter, extended Kalman filter, gps+imu fusion, EKF eskf gps+imu
- AcWing 608. Poor (implemented in C language)
- PrecomputedTextCompat用法及原理
- Using MySQL database in the express framework of node
- 杰理之wif 干扰蓝牙【篇】
- ByteV搭建动态数字孪生网络安全平台----助力网络安全发展
- Levels – virtual engine scene production "suggestions collection"
- 请问通达信股票软件可靠吗?在上面交易股票安全吗?
- 双缓冲绘图
- Vivo手机的权限管理
猜你喜欢
How to deploy the software testing environment?
【Unity编辑器扩展基础】、EditorGUILayout (三)
What is data compliance? How to achieve data compliance?
Deep learning has a new pit! The University of Sydney proposed a new cross modal task, using text to guide image matting
【C语言】结构体嵌套二级指针的使用
Leetcode 48. 旋转图像(可以,已解决)
UGUI强制刷新Layout(布局)组件
Web3 security serials (3) | in depth disclosure of NFT fishing process and prevention techniques
Redis principle - List
[vi/vim] basic usage and command summary
随机推荐
AcWing 604. Area of circle (implemented in C language)
自定义标题栏View
如何获取泛型的类型
洛谷_P1303 A*B Problem_高精度计算
Three ways to implement LRU cache (recommended Collection)
杰理之wif 干扰蓝牙【篇】
Remoteviews layout and type restriction source code analysis
fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
[vi/vim] basic usage and command summary
IDEA全局搜索快捷设置
Cohere, a large model company, completed the round B financing of US $125million
张同学回应首场直播带货
AcWing 608. Poor (implemented in C language)
After importing resources, unity also manually modifies the properties of resources? This code can save you a lot of time: assetpostprocessor
杰理之SPI1外挂FLASH录音修改【篇】
Is there a threshold for opening futures accounts? How to open futures accounts safely on the Internet
. Net hybrid development solution 24 webview2's superior advantages over cefsharp
Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
Pyqt5 visual development
Build your own website (18)