当前位置:网站首页>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();
}
}
边栏推荐
- 谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
- There are many ways to realize the pause function in JS
- Leetcode-231-2的幂
- 模拟Servlet的本质
- How can laravel get the public path
- JS 模块化
- What else can an ordinary person do besides working in a factory to make money?
- Regular expression string
- A JS script can be directly put into the browser to perform operations
- Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
猜你喜欢

Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
![[vulnhub range] thales:1](/img/fb/721d08697afe9b26c94fede628c4d1.png)
[vulnhub range] thales:1

【Android -- 数据存储】使用 SQLite 存储数据

Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!

torch.numel作用

AE learning 01: AE complete project summary

You Yuxi, coming!

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"?

Description of vs common shortcut keys

平衡二叉树(AVL)
随机推荐
How does geojson data merge the boundaries of regions?
How does laravel run composer dump autoload without emptying the classmap mapping relationship?
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
分类模型评价标准(performance measure)
IP地址和物理地址有什么区别
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
hellogolang
Notification uses full resolution
统计学习方法——感知机
Unity3D_ Class fishing project, bullet rebound effect is achieved
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
企业级日志分析系统ELK
URL和URI的关系
PHP has its own filtering and escape functions
Description of vs common shortcut keys
How to query the data of a certain day, a certain month, and a certain year in MySQL
Continuous creation depends on it!
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
JS 模块化