unity引用查找插件-ReferenceFinder

简介

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

使用示例

  右键需要查找引用的文件或文件夹,点击Find References进行查找。
1362861-20190409010249044-1682628333.png
按钮含义:
Refresh Data:刷新缓存
Model:切换引用和依赖
NeedUpdateState:是否需要根据当前文件的状态更新State栏。
Expand:展开列表
Collapse:折叠列表
1362861-20190409010311290-1583491535.png
1362861-20190409010316144-2054793630.png
  第三列的State为Changed代表这个资源被修改了,Missing代表资源被删除了,No Data代表缓存中没有该资源的信息。

实现方案

方案选择

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

  这里选择了方案二。

查找及缓存

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

界面实现

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

项目链接:Reference Finder

转载于:https://www.cnblogs.com/blueberryzzz/p/10674581.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
https://assetstore.unity.com/packages/tools/find-reference-2-59092 FR2 helps instantly clean up asset references for your projects Email | Documentation | Forum Why FR2? - Optimize your projects reference to minimize build size - Split your big projects to smaller / managable modules - Safely remove all duplicated assets - Safely replace prefabs / materials / shader with another one - Remove obsolete assets that you don't need anymore How can FR2 help? Just select one or more asset in Project panel and FR2 will show you: - Exactly what's being included in each scene or in each prefab. Remember that one redundant reference may resulted in asset being duplicated in each assetbundles and increase AssetBundle build sizes (Animation / Texture / Audio duplication) or degrade performance (Material duplication - increase drawcalls) - Which assets referenced to and make selected assets included in the build. This will help you confident that intermediate project assets will not be included in final build - Duplicated assets you may accidentally copy over and over. Using FR2 you can then redidrect all those references to a single copy of your choice and safely delete other duplications (usage count of those assets should now be 0) - See all assets not being referenced by any other asset so you can delete them all without worrying about breaking any references. - GUID Tools Advanced tool where you can see GUID of each asset and redirect references from one asset to another You can use this to redirect all references to TextureA (using TextureA) to TextureB, the same applied for shader, materials, mesh... Beware that replace references is very powerful yet dangerous operation you'd better don't use it if you don't understand how GUID works in Unity Other Features - Full C# source code - Top notch support 24/7 - Blazing fast - built for HUGE PROJECTS - Support with Unity 4.3+ and Unity 5.x - Quickly disable FR2 when not in used (zeroing performance cost) - Display usage count in project panel so you know which asset being used and how many times it's being used - Find script dependencies (experimental, C# only) - Export assets with references

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值