当前位置:网站首页>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();
}
}
边栏推荐
- Common training data set formats for target tracking
- Xcode Revoke certificate
- Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
- Laravel 中config的用法
- What is the difference between IP address and physical address
- HAVE FUN | “飞船计划”活动最新进展
- You Yuxi, coming!
- Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
- laravel 是怎么做到运行 composer dump-autoload 不清空 classmap 映射关系的呢?
- Performance measure of classification model
猜你喜欢

How does geojson data merge the boundaries of regions?

Three. JS introductory learning notes 19: how to import FBX static model

2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo

95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)

Odoo integrated plausible embedded code monitoring platform

pycharm 终端部启用虚拟环境

SPI master RX time out interrupt

AE learning 02: timeline

HAVE FUN | “飞船计划”活动最新进展

平衡二叉树(AVL)
随机推荐
torch.numel作用
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
Use moviepy Editor clips videos and intercepts video clips in batches
Unity3d click events added to 3D objects in the scene
删除 console 语句引发的惨案
Logback logging framework third-party jar package is available for free
[summary of knowledge] summary of notes on using SVN in PHP
Performance measure of classification model
laravel post提交数据时显示异常
Introduction to ThinkPHP URL routing
How to implement backspace in shell
What else can an ordinary person do besides working in a factory to make money?
Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
laravel中将session由文件保存改为数据库保存
23. 合并K个升序链表-c语言
模拟Servlet的本质
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
一个普通人除了去工厂上班赚钱,还能干什么工作?
prometheus api删除某个指定job的所有数据