当前位置:网站首页>Find tags in prefab in unity editing mode
Find tags in prefab in unity editing mode
2022-07-07 16:26:00 【Le_ Sam】
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
public class TestTTTT : EditorWindow
{
static Dictionary<int, List<GameObject>> layerDic = new Dictionary<int, List<GameObject>>();
static string findTag = "m_Layer";
[MenuItem("TestTTTT/ Find references #&R", false, 10)]
public static void ShowWindow()
{
GetWindow<TestTTTT>(" Find references ").Show();
}
private void OnGUI()
{
if (GUILayout.Button("Spawn"))
{
Find();
}
}
static private void Find()
{
string[] paths = AssetDatabase.GetAllAssetPaths();
// Load all prefab resources
var gos = paths.Where(path => path.EndsWith("prefab")).Select(path => AssetDatabase.LoadAssetAtPath<GameObject>(path));
var sum = 0;
foreach (var item in gos)
{
if (sum >= 10)
break;
GameObject go = item as GameObject;
if (go == null)
{
continue;
}
//sum++;
var resPath = AssetDatabase.GetAssetPath(item);
Component[] cps = go.GetComponentsInChildren<Component>(true);
List<int> layers = new List<int>();
var count = 0;
foreach (var cp in cps)
{
if (cp != null)
{
SerializedObject so = new SerializedObject(cp);
var property = so.FindProperty(findTag);
if (property != null)
{
var layer = property.intValue;
if (!layers.Contains(layer))
{
layers.Add(layer);
}
}
EditorUtility.DisplayProgressBar(" Find references ", resPath, count++ / (float)cps.Length);
//Debug.LogError($"resPath:{resPath} property:[{property?.intValue}]");
}
}
foreach (var layer in layers)
{
if (!layerDic.TryGetValue(layer, out var list))
{
list = new List<GameObject>();
layerDic[layer] = list;
}
if (!list.Contains(item))
{
list.Add(item);
}
}
}
Debug.LogError($"Keys:{layerDic.Keys.Count}");
foreach (var layer in layerDic.Keys)
{
Debug.LogError($"layer:{layer}");
}
Resources.UnloadUnusedAssets();
EditorUtility.ClearProgressBar();
}
}
边栏推荐
- Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
- Unity3d click events added to 3D objects in the scene
- Aerospace Hongtu information won the bid for the database system research and development project of a unit in Urumqi
- prometheus api删除某个指定job的所有数据
- 预测——灰色预测
- Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
- Sysom case analysis: where is the missing memory| Dragon lizard Technology
- markdown公式编辑教程
- Shader basic UV operations, translation, rotation, scaling
- How does geojson data merge the boundaries of regions?
猜你喜欢
What are compiled languages and interpreted languages?
Odoo集成Plausible埋码监控平台
Notification uses full resolution
Application example of infinite list [uigridview]
Dotween -- ease function
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
Vs tool word highlight with margin
HAVE FUN | “飞船计划”活动最新进展
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
随机推荐
记一次项目的迁移过程
Mysql database backup script
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
Asyncio concept and usage
Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
Usage of config in laravel
PHP has its own filtering and escape functions
What are compiled languages and interpreted languages?
Prometheus API deletes all data of a specified job
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
There are many ways to realize the pause function in JS
prometheus api删除某个指定job的所有数据
如何快速检查钢网开口面积比是否符合 IPC7525
Tragedy caused by deleting the console statement
模仿企业微信会议室选择
通知Notification使用全解析
PHP实现执行定时任务的几种思路详解
Set the route and optimize the URL in thinkphp3.2.3
Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()