【Unity3d】查看引用资源的文件
2017-07-09 16:42
393 查看
有的时候我们要管理资源,需要知道一个脚本或者一张图片有没有被引用,能不能删除。看到雨松大大的一篇文章正好是实现的这个功能,这里把脚本提取出来。
原本地址:Unity3D研究院之查找资源被哪里引用了
新建一个FindReferences.cs脚本,然后将如下能内容复制进去:
之后再Project视图里右击要查看的资源就可以选择Find References来进行搜索。
By:蒋志杰
原本地址:Unity3D研究院之查找资源被哪里引用了
新建一个FindReferences.cs脚本,然后将如下能内容复制进去:
using UnityEngine; using UnityEditor; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class FindReferences { [MenuItem("Assets/Find References", false, 130)] static private void Find() { EditorSettings.serializationMode = SerializationMode.ForceText; string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (!string.IsNullOrEmpty(path)) { string guid = AssetDatabase.AssetPathToGUID(path); string withoutExtensions = "*.prefab*.unity*.mat*.asset"; string[] files = Directory.GetFiles(Application.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<Object>(GetRelativeAssetsPath(file))); } 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('\\', '/'); } }
之后再Project视图里右击要查看的资源就可以选择Find References来进行搜索。
By:蒋志杰
相关文章推荐
- Android推荐一个查看资源文件引用次数的小插件
- 移动项目开发笔记(总结MasterPage中的资源文件引用路径)
- 如何在DNN模块中插入一个图片--在模块中引用资源文件
- 资源文件的引用方法-记号
- Winform项目中无法引用资源文件中图片的解决方法
- WPF 文件级资源(类似与使用CSS文件,然后引用CSS文件)
- 一行代码引用资源文件
- myeclipse6.0安装查看资源文件的插件
- .net winform 从资源文件中引用图片资源
- 查看修改apk里resources.arsc的资源文件的工具
- mfc 操作,添加menu资源,默认为IDR_MENU1...要修改为其他的名字则,在资源里头文件resourse.h中 加 #define IDR_OPEN_SHAP 130,然后打开资源文件shp_show.rc->查看代码,把menu1修改为IDR_OPEN_SHAP
- 莫名其妙的Silverlight资源文件引用问题
- 引用:silverlight 资源文件路径设置
- javascript查看页面引用什么CSS文件
- [转]总结MasterPage中的资源文件引用路径
- 总结MasterPage中的资源文件引用路径
- SilverLight学习笔记--关于Silverlight资源文件(如:图片)的放置位置及其引用
- 引用 ubuntu中查看各种设备和资源的命令汇总
- struts2引用国际化资源文件
- Android xml资源文件中@、@android:type、@*、?、@+引用写法含义以及区别