Unity3d 查找所选的是否引用过某资源
2016-04-18 20:08
507 查看
一、使用方式:
1、选择要被查找的资源,右键->Find Reference
2、把资源拽入Res,点Find
3、输出结果见Console
//代码
1、选择要被查找的资源,右键->Find Reference
2、把资源拽入Res,点Find
3、输出结果见Console
//代码
using UnityEngine; using System; using System.Collections; using UnityEditor; using System.Collections.Generic; public class FindReference : ScriptableWizard { public UnityEngine.Object Res; // Use this for initialization void Start() { } [MenuItem("Assets/Find Reference")] public static void OpenDialog() { DisplayWizard<FindReference>("Find Reference Object In Current Select", "Find", "Cancel"); } void OnWizardCreate() { Find(); } void OnWizardOtherButton() { Close(); } public void Find() { EditorUtility.DisplayProgressBar("Find Reference", "Finding...", 0); var instanceId = Res.GetInstanceID(); var gos = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); string log = ""; int i = 0; try { foreach (var go in gos) { var assetPath = AssetDatabase.GetAssetPath(go.GetInstanceID()); var paths = AssetDatabase.GetDependencies(new[] { assetPath }); foreach (var path in paths) { var res = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object)); if (res.GetInstanceID() == instanceId) { log+= assetPath; log += "\n"; } } EditorUtility.DisplayProgressBar("Find Reference", assetPath, i / gos.Length); i++; } } catch (Exception e) { Debug.Log(e.Message); } finally { EditorUtility.ClearProgressBar(); } Debug.Log(log); } }
相关文章推荐
- 记一次基于Unity的Profiler性能分析
- 微软unity 注入mvc
- Unity 动画模板代码注解
- Unity3D_NGUI_性能优化实践_CPU卡顿
- Unity3d 用NGUI制作做新手引导的思路
- 浅析:Unity3D开发的游戏如何降低包体大小
- 浅析:Unity3D开发的游戏如何降低包体大小
- 关于unity5.x破解不了的问题
- 在Unity 5中如何减少Draw Call
- Unity开发Leapmotion
- Unity WWW 和 AssetBundle只要将资源扔在服务器上就可以了吗?
- unity开发总结
- 【转】从Unity过渡到Unreal
- Unity3D 接入IOS SDK
- Unity3D学习日记(二)使用UGUI制作虚拟摇杆控制摄像机
- 关于Unity3D5.X 动态批处理(Dynamic Batching)实测,区别于4.0版本
- Unity VR 优化
- [Unity] Shader - CG语言 流程控制语句
- Unity依赖注入使用
- unity shader中的surfaceoutput问题