├── FindReferencesInProject.cs ├── FindReferencesInProject.cs.meta ├── LICENSE ├── LICENSE.meta ├── README.md └── README.md.meta /FindReferencesInProject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | public class FindReferencesInProject 7 | { 8 | private const string MenuItemText = "Assets/Find References In Project"; 9 | 10 | [MenuItem(MenuItemText, false, 25)] 11 | public static void Find() 12 | { 13 | var sw = new System.Diagnostics.Stopwatch(); 14 | sw.Start(); 15 | 16 | var referenceCache = new Dictionary>(); 17 | 18 | string[] guids = AssetDatabase.FindAssets(""); 19 | foreach (string guid in guids) 20 | { 21 | string assetPath = AssetDatabase.GUIDToAssetPath(guid); 22 | string[] dependencies = AssetDatabase.GetDependencies(assetPath, false); 23 | 24 | foreach (var dependency in dependencies) 25 | { 26 | if (referenceCache.ContainsKey(dependency)) 27 | { 28 | if (!referenceCache[dependency].Contains(assetPath)) 29 | { 30 | referenceCache[dependency].Add(assetPath); 31 | } 32 | } 33 | else 34 | { 35 | referenceCache[dependency] = new List(){ assetPath }; 36 | } 37 | } 38 | } 39 | 40 | Debug.Log("Build index takes " + sw.ElapsedMilliseconds + " milliseconds"); 41 | 42 | string path = AssetDatabase.GetAssetPath(Selection.activeObject); 43 | Debug.Log("Find: " + path, Selection.activeObject); 44 | if (referenceCache.ContainsKey(path)) 45 | { 46 | foreach (var reference in referenceCache[path]) 47 | { 48 | Debug.Log(reference, AssetDatabase.LoadMainAssetAtPath(reference)); 49 | } 50 | } 51 | else 52 | { 53 | Debug.LogWarning("No references"); 54 | } 55 | 56 | referenceCache.Clear(); 57 | } 58 | 59 | [MenuItem(MenuItemText, true)] 60 | public static bool Validate() 61 | { 62 | if (Selection.activeObject) 63 | { 64 | string path = AssetDatabase.GetAssetPath(Selection.activeObject); 65 | return !AssetDatabase.IsValidFolder(path); 66 | } 67 | 68 | return false; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /FindReferencesInProject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdd9e9bd1f333458f8054be3bb664874 3 | timeCreated: 1485696816 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 NETWORM 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f4ed3c75b6a447a297dba1fce187b92 3 | timeCreated: 1485757052 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Find References In Project 2 | 3 | Find asset references in Unity project. 4 | 5 | ## Install 6 | 7 | Copy `FindReferencesInProject.cs` or just clone this repository to Unity `Editor` directory. 8 | 9 | ## Usage 10 | 11 | Right click any asset in `Project` View and select `Find References In Project` in popup menu. 12 | 13 | ## Note 14 | 15 | This tool will first build asset reference cache, and it will consume a lot of time. So first output is the time consumed. 16 | 17 | You could click every output item in `Console` to select referenced asset. 18 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1baf17637efc423bb3b500d0e14b201 3 | timeCreated: 1485757052 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | --------------------------------------------------------------------------------