• Unity3d 查找所选的是否引用过某资源


    一、使用方式:

    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 += "
    ";
    					}
    				}
    				EditorUtility.DisplayProgressBar("Find Reference", assetPath, i / gos.Length);
    				i++;
    			}
    	    }
    	    catch (Exception e)
    	    {
    			Debug.Log(e.Message);
    	    }
    	    finally
    	    {
    			EditorUtility.ClearProgressBar();
    	    }
    		
    
    		Debug.Log(log);
        }
    
        
    
    }
    

      

  • 相关阅读:
    AVL树入门
    hdu 3709 Balanced Number
    跟着病毒学技术--学习WannaCry自己实现LoadLirbrary
    Win7下64位扫雷逆向以及辅助制作
    Qt使用.lib静态库和.dll动态库文件
    X64调用规范
    “热补丁”Hook,多线程下InlineHook解决方法
    x86 x64下调用约定浅析
    配置Sublime Text3编译汇编并高亮代码
    反调试技术(一)--静态反调试
  • 原文地址:https://www.cnblogs.com/mrblue/p/5405704.html
Copyright © 2020-2023  润新知