Unity 一键查看资源引用工具
2018-03-01 16:56
471 查看
using UnityEngine; using System.Collections; using UnityEditor; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; public class FindReferences { [MenuItem("Assets/Find References", false, 100)] static private void Find() { EditorSettings.serializationMode = SerializationMode.ForceText; string path = AssetDatabase.GetAssetPath(Selection.activeObject); string dataPath = Application.dataPath + "/Resources/UI"; if (!string.IsNullOrEmpty(path)) { string guid = AssetDatabase.AssetPathToGUID(path); List<string> withoutExtensions = new List<string>() { ".prefab", ".unity", ".mat", ".asset" }; string[] files = Directory.GetFiles(dataPath, "*.*", SearchOption.AllDirectories) .Where(s => withoutExtensions.Contains(Path.GetExtension(s).ToLower())).ToArray(); int startIndex = 0; EditorApplication.update = delegate() { string file = files[startIndex]; bool isCancel = EditorUtility.DisplayCancelableProgressBar("匹配资源中", file, (float)startIndex / (float)files.Length); if (Regex.IsMatch(File.ReadAllText(file), guid)) { Debug.Log(file, AssetDatabase.LoadAssetAtPath(GetRelativeAssetsPath(file), typeof(Object))); } startIndex++; if (isCancel || startIndex >= files.Length) { EditorUtility.ClearProgressBar(); EditorApplication.update = null; startIndex = 0; Debug.Log("匹配结束"); } }; } } [MenuItem("Assets/Find References", true)] static private bool VFind() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); return (!string.IsNullOrEmpty(path)); } static private string GetRelativeAssetsPath(string path) { return "Assets" + Path.GetFullPath(path).Replace(Path.GetFullPath(Application.dataPath), "").Replace('\\', '/'); } }
将此将本放到Editor文件夹下面,然后右键你要查看的资源,选择FindReferences,然后再打印区就会看到所有引用这个选中的资源的预设体了,很方便!
相关文章推荐
- [引擎]之四:unity中查看简单mesh顶点顺序的小工具——修改
- UE4引擎查看资源相互引用的情况
- 可视化反编译APK工具,查看部分JAVA代码与全部资源文件。
- Android Studio怎样查看资源或者函数在哪些类中被引用
- Unity编辑器 - 资源批处理工具基类
- 网络文件资源管理系统需要引用到的第三方工具或组件
- 能解开assetbundle格式资源的UnityStudio工具
- Android推荐一个查看资源文件引用次数的小插件
- 如何查看迅雷等资源共享工具正在上传的文件
- Unity工具 - 资源搜索
- 一键访问Win8.1 Update的磁盘空间查看资源占用情况
- unity编辑器扩展 SVN一键更新工具
- 使用KRPano资源分析工具一键下载全景网站切片图
- Spine输出资源一键入Unity3D工具代码
- 查看修改apk里resources.arsc的资源文件的工具
- 【Unity3d】查看引用资源的文件
- Unity 一键更换字体工具
- 使用Safari浏览器自带工具,查看页面中 css 样式的引用~
- 引用 ubuntu中查看各种设备和资源的命令汇总
- Systemtap工具查看系统资源使用