Skip to content

A Unity Editor plugin to find asset references and dependencies. It caches reference info and displays results in a tree view. Supports Windows and macOS. 一个用于 Unity 工程的插件,用来查找资源引用和依赖。 通过缓存保存资源间的引用信息,并以树状结构直观展示。 支持 Windows 和 macOS。

License

Notifications You must be signed in to change notification settings

anasiaqi/ReferenceFinder_U1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



[Here is the modified version description] 【以下是修改版的说明】





ReferenceFinder_U1 / Unity资源引用查找器(改进版)

This is a fork of ReferenceFinder with additional cross-platform support, recursive dependency scanning, UI/UX improvements, and workflow enhancements.

本仓库是 ReferenceFinder 的分支版本,增加了跨平台支持、递归依赖扫描、界面与体验改进以及工作流优化。


✨ What's New / 改进功能

Cross-platform Support / 跨平台支持

  • Windows: Keeps using the native FlatBuffers DLL cache for instant loading.
  • macOS/Linux: Skip the DLL (no errors), automatically fall back to full scan.

Windows 继续使用原生 DLL 缓存加速;macOS/Linux 自动跳过 DLL,不再报错,改为全量扫描。


Dependency Scanning / 依赖扫描优化

  • Fixed resource detection: no longer relies on File.Exists("Assets/...").
  • Recursive dependency analysis (GetDependencies(path, true)), so indirect references are correctly detected:
    • Prefab → Material → Texture
    • Scene → Prefab
    • Prefab Variants
    • SpriteAtlas

修复了 File.Exists 的路径误判问题;依赖分析改为递归,支持检测间接引用(Prefab → 材质 → 贴图、场景 → Prefab、Prefab 变体、SpriteAtlas 等)。


UI Improvements / 界面改进

  • Buttons now auto-adjust width to avoid text being cut.
  • Need Update State renamed to Check Missing/Changed State, with:
    • Tooltip explanation
    • ? help button showing a dialog
    • Marks assets as MISSING / CHANGED / NORMAL

按钮宽度自动适配,避免文字被截断。
Need Update State 重命名为 Check Missing/Changed State,并增加:提示信息、帮助按钮、状态标记(缺失 / 改变 / 正常)。


Workflow Enhancements / 使用体验提升

  • Refresh Data button:
    • Normal click: Try cache → fallback to full scan
    • Alt+Click: Force full scan (ignore cache)
  • Status display in toolbar: Shows last operation + duration, e.g.:
    • Status: Loaded from cache 0.34s
    • Status: Full scan (Alt) 12.8s

刷新按钮:普通点击优先使用缓存,Alt+点击强制全量扫描。
工具栏右上角显示最近操作状态与耗时。


Installation and Usage / 安装与使用

  1. Clone or download this repository, and place the folder into your Unity project’s Assets/ directory.
    克隆或下载 本仓库,并将文件夹放入你 Unity 工程的 Assets/ 目录下。

  2. Open Unity. You can access the tool in two ways:
    打开 Unity。有两种方式可以使用该工具:

    • From the top menu: Window → Reference Finder
    • Or by right-clicking an asset in the Project window and choosing Find References In Project
    • 顶部菜单进入:Window → Reference Finder
    • 或者在 Project 面板中右键点击资源,选择 Find References In Project



[Here is the original README content] 【以下是原始 README 内容 】





简介

  这是一个用来查找资源引用和依赖的插件,通过缓存来保存资源间的引用信息,通过树状结构直观的展示。
  由于是通过缓存进行实现的,所以在希望的到精确的引用信息时需要刷新缓存。不过由于缓存的存在,在资源改动较少的情况下,刷新速度较快,对使用影响较小。
  直接将文件夹拖到项目中即可使用。

环境

  • Unity 2018.4.0f1
  • Unity 2017.4.35f1
  • Unity 5.6.6f2

使用示例

  右键需要查找引用的文件或文件夹,点击 Find References In Project 进行查找。

按钮含义:
Refresh Data:刷新缓存 Model:切换引用和依赖 NeedUpdateState:是否需要根据当前文件的状态更新State栏。
Expand:展开列表 Collapse:折叠列表

  第三列的State为Changed代表这个资源被修改了,Missing代表资源被删除了,No Data代表缓存中没有该资源的信息。

实现方案

方案选择

  1.在每次需要查找时进行一次全局查找,保证查找的正确性。但是进行全局查找会很慢,因为查找资源依赖信息的接口GetDependencies本质上其实是对文本的查找(比如prefab中会以文本的形式记录prefab所引用资源的guiid和fileid),在不进行多线程查询优化的情况下这是一个很慢的过程,存储在机械硬盘上时会更慢。
  2.进行一次全局查找生成缓存,在进行查找时直接读取缓存(在资源改动时会出现引用信息不准确的问题),在资源变动时需要更新缓存,保持查找的正确性,不过由于缓存的存在,在资源没有太大的改动的情况下,刷新速度较快。

  这里选择了方案二。

查找及缓存

引用信息的生成:
  通过AssetDatabase.GetAllAssetPaths()获取项目中所有的资源路径。
  通过AssetDatabase.GetDependencies()获取每一个资源所依赖资源的信息。
  经过这两步之后就有了所有资源的依赖信息了。
  通过资源的依赖信息,我们就可以生成所有资源的引用信息了。
缓存:
  为了让缓存尽量的小,所以缓存只保存每个资源的guid、引用资源哈希值、依赖资源的信息。   其中引用资源哈希值时用于判断这个资源依赖的资源是否有修改,若有修改,则在刷新资源引用信息的时候需要重新读取这个资源的依赖信息,否则继续使用该信息。这个判断就是在资源改动较少时减少刷新时间的关键。
  在记录依赖时,没有直接记录依赖资源的guid,而是记录了资源在缓存中下标的位置,从而进一步缩小缓存的大小。

界面实现

  主要使用了Unity自带的TreeView实现树形界面的展示。

About

A Unity Editor plugin to find asset references and dependencies. It caches reference info and displays results in a tree view. Supports Windows and macOS. 一个用于 Unity 工程的插件,用来查找资源引用和依赖。 通过缓存保存资源间的引用信息,并以树状结构直观展示。 支持 Windows 和 macOS。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%