├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── main.yml │ └── npm-publish.yml ├── .gitignore ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── Documentation~ └── shotscreen1.png ├── Editor.meta ├── Editor ├── Compents.meta ├── Compents │ ├── SelectWindow.cs │ ├── SelectWindow.cs.meta │ ├── SimpleTreeView.cs │ └── SimpleTreeView.cs.meta ├── Core.meta ├── Core │ ├── FindAssetWindowBase.cs │ ├── FindAssetWindowBase.cs.meta │ ├── FindWindowBase.cs │ └── FindWindowBase.cs.meta ├── Finder.cs ├── Finder.cs.meta ├── IFinderWindow.cs ├── IFinderWindow.cs.meta ├── MenuItems.cs ├── MenuItems.cs.meta ├── SearchAssetType.cs ├── SearchAssetType.cs.meta ├── ShaderType.cs ├── ShaderType.cs.meta ├── Utils.meta ├── Utils │ ├── EditorGUILayoutUtil.cs │ ├── EditorGUILayoutUtil.cs.meta │ ├── EditorUtil.cs │ ├── EditorUtil.cs.meta │ ├── FindUtil.cs │ ├── FindUtil.cs.meta │ ├── ListPool.cs │ ├── ListPool.cs.meta │ ├── ObjectPool.cs │ ├── ObjectPool.cs.meta │ ├── ReflectionMethodsCache.cs │ ├── ReflectionMethodsCache.cs.meta │ ├── SearchableEditorWindowUtil.cs │ ├── SearchableEditorWindowUtil.cs.meta │ ├── SelectionUtil.cs │ ├── SelectionUtil.cs.meta │ ├── TypeCache.cs │ ├── TypeCache.cs.meta │ ├── UnityUtil.cs │ └── UnityUtil.cs.meta ├── Windows.meta ├── Windows │ ├── FindFontInPrefab.cs │ ├── FindFontInPrefab.cs.meta │ ├── FindMaterialByShader.cs │ ├── FindMaterialByShader.cs.meta │ ├── FindMaterialByTexture.cs │ ├── FindMaterialByTexture.cs.meta │ ├── FindMissingOnAllAssets.cs │ ├── FindMissingOnAllAssets.cs.meta │ ├── FindMissingOnCurrentScene.cs │ ├── FindMissingOnCurrentScene.cs.meta │ ├── FindMissingPropertyOnAllAssets.cs │ ├── FindMissingPropertyOnAllAssets.cs.meta │ ├── FindMissingPropertyOnCurrentScene.cs │ ├── FindMissingPropertyOnCurrentScene.cs.meta │ ├── FindPrefabByAnimation.cs │ ├── FindPrefabByAnimation.cs.meta │ ├── FindPrefabByAudio.cs │ ├── FindPrefabByAudio.cs.meta │ ├── FindPrefabByChildrenName.cs │ ├── FindPrefabByChildrenName.cs.meta │ ├── FindPrefabByMaterial.cs │ ├── FindPrefabByMaterial.cs.meta │ ├── FindPrefabByScript.cs │ ├── FindPrefabByScript.cs.meta │ ├── FindPrefabByShader.cs │ ├── FindPrefabByShader.cs.meta │ ├── FindPrefabBySprite.cs │ ├── FindPrefabBySprite.cs.meta │ ├── FindPrefabByTextue.cs │ ├── FindPrefabByTextue.cs.meta │ ├── FindSprite.cs │ ├── FindSprite.cs.meta │ ├── FindText.cs │ ├── FindText.cs.meta │ ├── FindUsage.cs │ ├── FindUsage.cs.meta │ ├── FindUsageOnCurrentScene.cs │ └── FindUsageOnCurrentScene.cs.meta ├── com.litefeel.Finder.Editor.asmdef └── com.litefeel.Finder.Editor.asmdef.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── package.json └── package.json.meta /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: "https://www.paypal.me/litefeel" 13 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: {} 5 | push: {} 6 | 7 | # env: 8 | # UNITY_LICENSE_FILE: UnityLicense/2019.2.11f1.ulf 9 | 10 | jobs: 11 | Test: 12 | name: Test ${{ matrix.unityVersion }} ${{ matrix.testMode }} 🔑 13 | runs-on: ubuntu-latest 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | unityVersion: 18 | - 2018.4.17f1 19 | - 2019.4.9f1 20 | - 2020.1.3f1 21 | steps: 22 | # Set env 23 | - name: Set env UNITY_LICENSE_FILE 24 | run: echo ::set-env name=UNITY_LICENSE_FILE::UnityLicense/${{ matrix.unityVersion }}.ulf 25 | 26 | # Checkout Empty Project 27 | - name: Checkout Empty Project 28 | uses: actions/checkout@v2 29 | with: 30 | repository: litefeel/UnityEmptyProject 31 | 32 | # Checkout this project 33 | - name: Checkout repository 34 | uses: actions/checkout@v2 35 | with: 36 | lfs: true 37 | path: Packages/MyPlugin 38 | 39 | # Cache 40 | - uses: actions/cache@v1.1.0 41 | with: 42 | path: Library 43 | key: Library 44 | 45 | # Test 46 | - name: Run tests 47 | uses: webbertakken/unity-test-runner@v1.6 48 | id: tests 49 | with: 50 | customParameters: "-nographics" 51 | unityVersion: ${{ matrix.unityVersion }} 52 | 53 | # # Build 54 | # - name: Build project 55 | # uses: litefeel/unity-builder@v0.14 56 | # with: 57 | # unityVersion: ${{ matrix.unityVersion }} 58 | # targetPlatform: WebGL 59 | 60 | # Output 61 | - uses: actions/upload-artifact@v1 62 | name: Upload tests 63 | with: 64 | name: Test results for ${{ matrix.testMode }} on unity ${{ matrix.unityVersion }} 65 | path: ${{ steps.tests.outputs.artifactsPath }} 66 | 67 | # - uses: actions/upload-artifact@v1 68 | # name: Upload build 69 | # with: 70 | # name: Build 71 | # path: build -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/publish-to-npm 2 | 3 | name: npm-publish 4 | on: 5 | push: 6 | branches: 7 | - master # Change this to your default branch 8 | jobs: 9 | npm-publish: 10 | name: npm-publish 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@master 15 | - name: Set up Node.js 16 | uses: actions/setup-node@master 17 | with: 18 | node-version: 10.0.0 19 | - name: Publish if version has been updated 20 | uses: pascalgn/npm-publish-action@06e0830ea83eea10ed4a62654eeaedafb8bf50fc 21 | with: # All of theses inputs are optional 22 | tag_name: "%s" 23 | tag_message: "%s" 24 | commit_pattern: "^Release (\\S+)" 25 | workspace: "." 26 | env: # More info about the environment variables in the README 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated 28 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Never ignore Asset meta data 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | v1.0.1 Sep 1 2020 3 | [NEW] Add FindPrefabBySprite 4 | [NEW] Add FindUsageOnCurrentScene 5 | [NEW] Support input class name for FindPrefabByScript 6 | [NEW] Support npm package 7 | [FIX] Fix some error 8 | 9 | v1.0.0 Jan 1 2020 10 | [NEW] The first public version 11 | -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f087be4bccadc3144abbb89c3a312c77 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Documentation~/shotscreen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/litefeel/Unity-Finder/bcf88c523538c69a48a23835d93fbeb074abc7fc/Documentation~/shotscreen1.png -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61175bbb731b6a54fb0f405cb1218f11 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Compents.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0794545d06c904349bb8981a920c700c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Compents/SelectWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEditor; 5 | using UnityEditor.IMGUI.Controls; 6 | using UnityEngine; 7 | using UnityEngine.UI; 8 | using UnityObject = UnityEngine.Object; 9 | 10 | namespace litefeel.Finder.Editor 11 | { 12 | class SelectWindow : EditorWindow 13 | { 14 | 15 | //[MenuItem("XXXXX/XXXX")] 16 | public static void XXXX() 17 | { 18 | var names = TypeCache.GetFullNames(); 19 | var types = TypeCache.GetTypes(); 20 | SelectWindow.get.Show(names, null, (index)=> 21 | { 22 | if(index >= 0 && index < types.Count) 23 | { 24 | var type = types[index]; 25 | return type.FullName; 26 | } 27 | return "None"; 28 | }); 29 | } 30 | 31 | static SelectWindow s_SharedObjectSelector = null; 32 | public static SelectWindow get 33 | { 34 | get 35 | { 36 | if (s_SharedObjectSelector == null) 37 | { 38 | UnityObject[] objs = Resources.FindObjectsOfTypeAll(typeof(SelectWindow)); 39 | if (objs != null && objs.Length > 0) 40 | s_SharedObjectSelector = (SelectWindow)objs[0]; 41 | if (s_SharedObjectSelector == null) 42 | s_SharedObjectSelector = ScriptableObject.CreateInstance(); 43 | } 44 | return s_SharedObjectSelector; 45 | } 46 | } 47 | 48 | [SerializeField] 49 | protected TreeViewState m_TreeViewState; 50 | [SerializeField] 51 | protected SimpleTreeView m_SimpleTreeView; 52 | 53 | protected List m_ItemNames = new List(); 54 | private string m_SearchFilter; 55 | private bool m_FocusSearchFilter; 56 | 57 | private int m_SelectedIdx = -1; 58 | 59 | private Action m_OnSelectedCallback; 60 | private Func m_DetailFunc; 61 | private float previewHeight = 20f; 62 | 63 | public void Show(List list, Action selectIndexCallback, Func detailFunc = null) 64 | { 65 | m_OnSelectedCallback = selectIndexCallback; 66 | m_DetailFunc = detailFunc ?? DefaultDetail; 67 | 68 | m_ItemNames.AddRange(list); 69 | ShowAuxWindow(); 70 | m_SimpleTreeView.Reload(); 71 | } 72 | protected virtual void OnEnable() 73 | { 74 | titleContent = new GUIContent("Select"); 75 | 76 | if (m_TreeViewState == null) 77 | m_TreeViewState = new TreeViewState(); 78 | m_SimpleTreeView = new SimpleTreeView(m_TreeViewState); 79 | m_SimpleTreeView.onItemSelect = OnItemSelect; 80 | m_SimpleTreeView.onItemClick = OnItemClick; 81 | m_SimpleTreeView.onItemDoubleClick = OnItemDoubleClick; 82 | m_SimpleTreeView.Items = m_ItemNames; 83 | m_SimpleTreeView.Reload(); 84 | } 85 | 86 | private void OnDisable() 87 | { 88 | m_ItemNames = null; 89 | m_DetailFunc = null; 90 | m_OnSelectedCallback = null; 91 | } 92 | 93 | protected virtual void OnItemSelect(int index) 94 | { 95 | m_SelectedIdx = index; 96 | m_OnSelectedCallback?.Invoke(index); 97 | } 98 | 99 | protected virtual void OnItemClick(int index) 100 | { 101 | m_OnSelectedCallback?.Invoke(index); 102 | } 103 | 104 | protected virtual void OnItemDoubleClick(int index) 105 | { 106 | m_OnSelectedCallback?.Invoke(index); 107 | Close(); 108 | } 109 | 110 | 111 | private void OnGUI() 112 | { 113 | OnObjectGridGUI(); 114 | } 115 | void OnObjectGridGUI() 116 | { 117 | //InitIfNeeded(); 118 | 119 | //if (m_EditorCache == null) 120 | // m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); 121 | 122 | //// Handle window/preview stuff 123 | //ResizeBottomPartOfWindow(); 124 | 125 | Rect p = position; 126 | //EditorPrefs.SetFloat("ObjectSelectorWidth", p.width); 127 | //EditorPrefs.SetFloat("ObjectSelectorHeight", p.height); 128 | 129 | GUI.BeginGroup(new Rect(0, 0, position.width, position.height), GUIContent.none); 130 | 131 | // Let grid/list area take priority over search area on up/down arrow keys 132 | //if (s_GridAreaPriorityKeyboardEvents.Contains(Event.current)) 133 | // m_ListArea.HandleKeyboard(false); 134 | 135 | SearchArea(); 136 | 137 | 138 | 139 | // Let grid/list area handle any keyboard events not used by search area 140 | //m_ListArea.HandleKeyboard(false); 141 | 142 | GridListArea(); 143 | PreviewArea(); 144 | 145 | GUI.EndGroup(); 146 | 147 | //// overlay preview resize widget 148 | //GUI.Label(new Rect(position.width * .5f - 16, position.height - m_PreviewSize + 2, 32, Styles.bottomResize.fixedHeight), GUIContent.none, Styles.bottomResize); 149 | } 150 | 151 | private void PreviewArea() 152 | { 153 | GUI.Box(new Rect(0, position.height - previewHeight, position.width, previewHeight), "", "PopupCurveSwatchBackground"); 154 | // Get info string 155 | var s = m_DetailFunc.Invoke(m_SelectedIdx) ?? ""; 156 | Rect labelRect = new Rect(20, position.height - previewHeight + 1, position.width - 22, 18); 157 | if (EditorGUIUtility.isProSkin) 158 | EditorGUI.DropShadowLabel(labelRect, s, "ObjectPickerSmallStatus"); 159 | else 160 | GUI.Label(labelRect, s, "ObjectPickerSmallStatus"); 161 | } 162 | 163 | private void GridListArea() 164 | { 165 | var rect = new Rect(2, 0, position.width - 4, position.height - previewHeight); 166 | rect.y = (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 2) * 1; 167 | rect.height -= rect.y + EditorGUIUtility.standardVerticalSpacing; 168 | m_SimpleTreeView.SetFilter(m_SearchFilter); 169 | GUILayout.BeginArea(rect, EditorStyles.textField); 170 | { 171 | rect.position = new Vector2(0, 0); 172 | m_SimpleTreeView.OnGUI(rect); 173 | } 174 | GUILayout.EndArea(); 175 | } 176 | 177 | void SearchArea() 178 | { 179 | // ESC clears search field and removes it's focus. But if we get an esc event we only want to clear search field. 180 | // So we need special handling afterwards. 181 | bool wasEscape = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape; 182 | 183 | string searchFilter = ReflectionMethodsCache.Singleton.ToolbarSearchField(m_SearchFilter); 184 | 185 | if (wasEscape && Event.current.type == EventType.Used) 186 | { 187 | // If we hit esc and the string WAS empty, it's an actual cancel event. 188 | //if (m_SearchFilter == "") 189 | // Cancel(); 190 | 191 | // Otherwise the string has been cleared and focus has been lost. We don't have anything else to recieve focus, so we want to refocus the search field. 192 | m_FocusSearchFilter = true; 193 | } 194 | 195 | if (searchFilter != m_SearchFilter || m_FocusSearchFilter) 196 | { 197 | m_SearchFilter = searchFilter; 198 | //FilterSettingsChanged(); 199 | // Repaint(); 200 | } 201 | 202 | 203 | // TAB BAR 204 | //GUILayout.BeginArea(new Rect(4, kToolbarHeight, position.width - 4, kToolbarHeight)); 205 | //GUILayout.BeginHorizontal(); 206 | 207 | ////bool showingSceneTab = !m_IsShowingAssets; 208 | ////GUIContent sceneLabel = StageNavigationManager.instance.currentItem.isPrefabStage ? Styles.selfTabLabel : Styles.sceneTabLabel; 209 | ////showingSceneTab = GUILayout.Toggle(showingSceneTab, sceneLabel, Styles.tab); 210 | ////if (m_IsShowingAssets && showingSceneTab) 211 | //// m_IsShowingAssets = false; 212 | 213 | 214 | 215 | //GUILayout.EndHorizontal(); 216 | //GUILayout.EndArea(); 217 | 218 | //if (GUI.changed) 219 | // FilterSettingsChanged(); 220 | 221 | //var size = new Vector2(0, 0); 222 | //if (m_IsShowingAssets) 223 | //{ 224 | // Styles.packagesVisibilityContent.text = PackageManagerUtilityInternal.HiddenPackagesCount.ToString(); 225 | // size = EditorStyles.toolbarButton.CalcSize(Styles.packagesVisibilityContent); 226 | //} 227 | 228 | //if (m_ListArea.CanShowThumbnails()) 229 | //{ 230 | // EditorGUI.BeginChangeCheck(); 231 | // var newGridSize = (int)GUI.HorizontalSlider(new Rect(position.width - (60 + size.x), kToolbarHeight + GUI.skin.horizontalSlider.margin.top, 55, EditorGUI.kSingleLineHeight), m_ListArea.gridSize, m_ListArea.minGridSize, m_ListArea.maxGridSize); 232 | // if (EditorGUI.EndChangeCheck()) 233 | // { 234 | // m_ListArea.gridSize = newGridSize; 235 | // } 236 | //} 237 | 238 | //if (m_IsShowingAssets) 239 | //{ 240 | // EditorGUI.BeginChangeCheck(); 241 | // var skipHiddenPackages = GUI.Toggle(new Rect(position.width - size.x, kToolbarHeight, size.x, EditorStyles.toolbarButton.fixedHeight), m_SkipHiddenPackages, Styles.packagesVisibilityContent, EditorStyles.toolbarButtonRight); 242 | // if (EditorGUI.EndChangeCheck()) 243 | // { 244 | // m_SkipHiddenPackages = skipHiddenPackages; 245 | // FilterSettingsChanged(); 246 | // } 247 | //} 248 | } 249 | 250 | private string DefaultDetail(int index) 251 | { 252 | if (index >= 0 && m_ItemNames.Count > index) 253 | { 254 | return m_ItemNames[m_SelectedIdx]; 255 | //string typeName = ObjectNames.NicifyVariableName(Name); 256 | //if (p != null) 257 | // s = p.name + " (" + typeName + ")"; 258 | //else 259 | // s = selectedObject.name + " (" + typeName + ")"; 260 | 261 | //s += " " + AssetDatabase.GetAssetPath(selectedObject); 262 | } 263 | return "None"; 264 | } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /Editor/Compents/SelectWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a40ae0fbb84a2824e8af7ae56bf05157 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Compents/SimpleTreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEditor.IMGUI.Controls; 5 | using UnityEngine; 6 | using UnityObject = UnityEngine.Object; 7 | 8 | namespace litefeel.Finder.Editor 9 | { 10 | class SimpleTreeView : TreeView 11 | { 12 | 13 | private TreeViewItem m_Root = new TreeViewItem(-1, -1, "Root"); 14 | private List m_TreeItems = new List(); 15 | 16 | public Action onItemSelect; 17 | public Action onItemClick; 18 | public Action onItemDoubleClick; 19 | 20 | private List m_Items = new List(); 21 | private string m_FilterStr; 22 | 23 | public List Items 24 | { 25 | get { return m_Items; } 26 | set { m_Items = value ?? new List(); } 27 | } 28 | 29 | 30 | public SimpleTreeView(TreeViewState treeViewState) 31 | : base(treeViewState) 32 | { 33 | Reload(); 34 | } 35 | 36 | public void SetFilter(string filterStr) 37 | { 38 | m_FilterStr = filterStr; 39 | if (string.IsNullOrWhiteSpace(m_FilterStr)) 40 | m_FilterStr = null; 41 | else 42 | m_FilterStr = m_FilterStr.ToLower(); 43 | Reload(); 44 | } 45 | 46 | protected override TreeViewItem BuildRoot() 47 | { 48 | // BuildRoot is called every time Reload is called to ensure that TreeViewItems 49 | // are created from data. Here we create a fixed set of items. In a real world example, 50 | // a data model should be passed into the TreeView and the items created from the model. 51 | 52 | // This section illustrates that IDs should be unique. The root item is required to 53 | // have a depth of -1, and the rest of the items increment from that. 54 | m_TreeItems.Clear(); 55 | for (var i = 0; i < m_Items.Count; i++) 56 | { 57 | if (m_FilterStr == null || m_Items[i].ToLower().Contains(m_FilterStr)) 58 | m_TreeItems.Add(new TreeViewItem(i, 0, m_Items[i])); 59 | } 60 | // Utility method that initializes the TreeViewItem.children and .parent for all items. 61 | SetupParentsAndChildrenFromDepths(m_Root, m_TreeItems); 62 | 63 | // Return root of the tree 64 | return m_Root; 65 | } 66 | 67 | protected override bool CanMultiSelect(TreeViewItem item) 68 | { 69 | return false; 70 | } 71 | 72 | protected override void DoubleClickedItem(int id) 73 | { 74 | onItemDoubleClick?.Invoke(id); 75 | } 76 | 77 | protected override void SingleClickedItem(int id) 78 | { 79 | onItemClick?.Invoke(id); 80 | } 81 | 82 | protected override void SelectionChanged(IList selectedIds) 83 | { 84 | onItemSelect?.Invoke(selectedIds[0]); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Editor/Compents/SimpleTreeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5b76318638db2b4c81e8b6bbd65931b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e1a49050bdc3664ebecb6ca01df583b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Core/FindAssetWindowBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEditor.IMGUI.Controls; 5 | using UnityEngine; 6 | using UnityObject = UnityEngine.Object; 7 | 8 | namespace litefeel.Finder.Editor 9 | { 10 | abstract class FindAssetWindowBase : FindWindowBase, IFinderWindow 11 | where TAsset : UnityObject 12 | where TObject : UnityObject 13 | { 14 | protected TAsset m_Asset; 15 | protected bool m_EnabledFindInScene; 16 | 17 | 18 | public virtual void InitAsset(UnityObject obj) 19 | { 20 | m_Asset = obj as TAsset; 21 | } 22 | 23 | protected override void OnGUIBody() 24 | { 25 | EditorGUILayout.BeginHorizontal(); 26 | { 27 | OnBeforeAssetUI(); 28 | m_Asset = EditorGUILayout.ObjectField(m_Asset, typeof(TAsset), false) as TAsset; 29 | OnGUIFindInScene(); 30 | } 31 | EditorGUILayout.EndHorizontal(); 32 | 33 | base.OnGUIBody(); 34 | } 35 | 36 | protected virtual void OnBeforeAssetUI() 37 | { 38 | 39 | } 40 | 41 | protected virtual void OnGUIFindInScene() 42 | { 43 | if (m_EnabledFindInScene) 44 | { 45 | if (GUILayout.Button("FindInScene", GUILayout.ExpandWidth(false))) 46 | OnClickFindInScene(); 47 | } 48 | } 49 | 50 | protected virtual string GetFindInSceneSearchFilter(ref SearchableEditorWindow.SearchMode searchMode) 51 | { 52 | string searchFilter; 53 | 54 | #if UNITY_2019_2_OR_NEWER 55 | // Don't remove "Assets" prefix, we need to support Packages as well (https://fogbugz.unity3d.com/f/cases/1161019/) 56 | string path = AssetDatabase.GetAssetPath(m_Asset); 57 | #else 58 | // only main assets have unique paths (remove "Assets" to make string simpler) 59 | string path = AssetDatabase.GetAssetPath(m_Asset).Substring(7); 60 | #endif 61 | if (path.IndexOf(' ') != -1) 62 | path = '"' + path + '"'; 63 | 64 | if (AssetDatabase.IsMainAsset(m_Asset)) 65 | searchFilter = "ref:" + path; 66 | else 67 | searchFilter = "ref:" + m_Asset.GetInstanceID() + ":" + path; 68 | 69 | return searchFilter; 70 | } 71 | 72 | protected virtual void OnClickFindInScene() 73 | { 74 | var searchMode = SearchableEditorWindow.SearchMode.All; 75 | var searchFilter = GetFindInSceneSearchFilter(ref searchMode); 76 | SearchableEditorWindowUtil.ForEach((win) => 77 | { 78 | win.SetSearchFilter(searchFilter, searchMode); 79 | }, HierarchyType.GameObjects); 80 | } 81 | 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Editor/Core/FindAssetWindowBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4470ffe7aee08543b83b9717bae22dd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Core/FindWindowBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEditor.IMGUI.Controls; 5 | using UnityEngine; 6 | using UnityObject = UnityEngine.Object; 7 | 8 | namespace litefeel.Finder.Editor 9 | { 10 | abstract class FindWindowBase : EditorWindow where TObject : UnityObject 11 | { 12 | protected bool m_DisableFind; 13 | protected string m_Message; 14 | 15 | // asset type for search 16 | private float m_FilterByTypeWith; 17 | protected GUIContent m_FilterByType; 18 | protected bool m_IgnoreScearchAssetType; 19 | protected SearchAssetType m_SearchAssetType; 20 | 21 | // asset folder for serach 22 | private float m_FilterByFolderWith; 23 | protected GUIContent m_FilterByFolder; 24 | protected bool m_IgnoreSearchAssetFolder; 25 | protected SearchAssetFolder m_SearchAssetFolder = SearchAssetFolder.Folder; 26 | protected DefaultAsset m_Folder; 27 | 28 | protected List m_ItemNames = new List(); 29 | protected List m_Items = new List(); 30 | 31 | 32 | [SerializeField] 33 | protected TreeViewState m_TreeViewState; 34 | [SerializeField] 35 | protected SimpleTreeView m_SimpleTreeView; 36 | 37 | private string m_FilterStr; 38 | 39 | private GUIStyle m_PopupStyle; 40 | private bool m_Inited; 41 | 42 | protected virtual void OnEnable() 43 | { 44 | if (m_TreeViewState == null) 45 | m_TreeViewState = new TreeViewState(); 46 | m_SimpleTreeView = new SimpleTreeView(m_TreeViewState); 47 | m_SimpleTreeView.onItemSelect = OnItemSelect; 48 | m_SimpleTreeView.onItemClick = OnItemClick; 49 | m_SimpleTreeView.onItemDoubleClick = OnItemDoubleClick; 50 | m_SimpleTreeView.Items = m_ItemNames; 51 | m_SimpleTreeView.Reload(); 52 | } 53 | 54 | private void Init() 55 | { 56 | if (m_Inited) return; 57 | m_Inited = true; 58 | 59 | m_PopupStyle = new GUIStyle(EditorStyles.popup); 60 | m_PopupStyle.fixedHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 61 | 62 | m_FilterByType = new GUIContent(EditorGUIUtility.FindTexture("FilterByType"), "Search by Type"); 63 | m_FilterByTypeWith = EditorUtil.CalcLabelSize(EditorGUILayoutUtil.GetDisplayName(SearchAssetType.Prefab), m_PopupStyle); 64 | 65 | m_FilterByFolder = new GUIContent(EditorGUIUtility.FindTexture("Project"), "Search by Folder"); 66 | m_FilterByFolderWith = EditorUtil.CalcLabelSize(EditorGUILayoutUtil.GetDisplayName(SearchAssetFolder.AssetsAndPackages), m_PopupStyle); 67 | } 68 | 69 | private void OnGUI() 70 | { 71 | Init(); 72 | if (Event.current.type == EventType.Layout) 73 | ConfigValues(); 74 | OnGUIBody(); 75 | } 76 | 77 | protected virtual void OnGUIBody() 78 | { 79 | EditorGUILayout.BeginHorizontal(); 80 | { 81 | using (new EditorGUI.DisabledScope(m_DisableFind)) 82 | { 83 | GUILayoutOption[] options = null; 84 | if (!m_IgnoreSearchAssetFolder) 85 | options = new GUILayoutOption[] { GUILayout.Width(EditorGUIUtility.labelWidth) }; 86 | if (GUILayout.Button("Find", options)) 87 | DoFind(); 88 | } 89 | 90 | OnGUISearchAssetType(); 91 | OnGUISearchAssetFolder(); 92 | 93 | } 94 | EditorGUILayout.EndHorizontal(); 95 | 96 | if (!string.IsNullOrEmpty(m_Message)) 97 | EditorGUILayout.HelpBox(m_Message, MessageType.Warning, true); 98 | 99 | EditorGUILayout.BeginHorizontal(); 100 | { 101 | var countStr = string.Format("Count:{0}", m_ItemNames.Count); 102 | EditorGUILayout.LabelField(countStr, GUILayout.Width(EditorUtil.CalcLabelSize(countStr))); 103 | GUILayout.FlexibleSpace(); 104 | using (new EditorGUI.DisabledScope(m_ItemNames.Count == 0)) 105 | { 106 | EditorGUILayout.LabelField("Filter:", GUILayout.Width(EditorUtil.CalcLabelSize("Filter:"))); 107 | var tmpStr = EditorGUILayout.TextField(m_FilterStr); 108 | if (tmpStr != m_FilterStr) 109 | { 110 | m_FilterStr = tmpStr; 111 | m_SimpleTreeView.SetFilter(m_FilterStr); 112 | } 113 | } 114 | } 115 | EditorGUILayout.EndHorizontal(); 116 | 117 | var rect = new Rect(2, 0, position.width - 4, position.height); 118 | rect.y = (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 2) * 3; 119 | rect.height -= rect.y + EditorGUIUtility.standardVerticalSpacing; 120 | GUILayout.BeginArea(rect, EditorStyles.textField); 121 | { 122 | m_SimpleTreeView.Items = m_ItemNames; 123 | rect.position = new Vector2(0, 0); 124 | m_SimpleTreeView.OnGUI(rect); 125 | if (m_ItemNames.Count == 0) 126 | EditorGUILayout.LabelField("No References"); 127 | } 128 | GUILayout.EndArea(); 129 | } 130 | 131 | protected virtual void ConfigValues() { } 132 | 133 | protected string[] GetSearchInFolders() 134 | { 135 | switch (m_SearchAssetFolder) 136 | { 137 | case SearchAssetFolder.Assets: 138 | return new string[] { "Assets" }; 139 | case SearchAssetFolder.AssetsAndPackages: 140 | return Array.Empty(); 141 | } 142 | if (m_Folder == null) 143 | return Array.Empty(); 144 | 145 | return new string[] { AssetDatabase.GetAssetPath(m_Folder) }; 146 | } 147 | 148 | protected virtual void OnGUISearchAssetType() 149 | { 150 | if (m_IgnoreScearchAssetType) return; 151 | 152 | EditorGUILayout.DropdownButton(m_FilterByType, FocusType.Passive, EditorStyles.largeLabel, GUILayout.ExpandWidth(false)); 153 | m_SearchAssetType = (SearchAssetType)EditorGUILayoutUtil.EnumPopup(m_SearchAssetType, m_PopupStyle, GUILayout.Width(m_FilterByTypeWith)); 154 | } 155 | 156 | protected virtual void OnGUISearchAssetFolder() 157 | { 158 | if (m_IgnoreSearchAssetFolder) return; 159 | 160 | EditorGUILayout.DropdownButton(m_FilterByFolder, FocusType.Passive, EditorStyles.largeLabel, GUILayout.ExpandWidth(false)); 161 | 162 | m_SearchAssetFolder = (SearchAssetFolder)EditorGUILayoutUtil.EnumPopup(m_SearchAssetFolder, m_PopupStyle, GUILayout.Width(m_FilterByFolderWith)); 163 | using (new EditorGUI.DisabledScope(m_SearchAssetFolder != SearchAssetFolder.Folder)) 164 | m_Folder = EditorGUILayout.ObjectField(m_Folder, typeof(DefaultAsset), false, GUILayout.ExpandWidth(true)) as DefaultAsset; 165 | } 166 | 167 | protected virtual void DoFind() 168 | { 169 | m_Items.Clear(); 170 | m_ItemNames.Clear(); 171 | Finder.ForeachPrefabAndScene((obj, path) => 172 | { 173 | bool has = false; 174 | switch (obj) 175 | { 176 | case SceneAsset _: 177 | has = FindUtil.InScene(path, InGameObjectAndChildren); 178 | break; 179 | case GameObject prefab: 180 | has = InGameObjectAndChildren(prefab); 181 | break; 182 | } 183 | if (has) 184 | { 185 | m_Items.Add((TObject)obj); 186 | m_ItemNames.Add(path); 187 | } 188 | }, true, GetSearchInFolders(), m_SearchAssetType); 189 | m_SimpleTreeView.Reload(); 190 | } 191 | 192 | protected abstract bool InGameObjectAndChildren(GameObject prefab); 193 | 194 | protected virtual void OnItemSelect(int index) 195 | { 196 | EditorGUIUtility.PingObject(m_Items[index]); 197 | } 198 | 199 | protected virtual void OnItemClick(int index) 200 | { 201 | EditorGUIUtility.PingObject(m_Items[index]); 202 | } 203 | 204 | protected virtual void OnItemDoubleClick(int index) 205 | { 206 | AssetDatabase.OpenAsset(m_Items[index]); 207 | } 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /Editor/Core/FindWindowBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08ad1712811f3e34bbc5fdf928caad3c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Finder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEditor; 5 | using UnityEditor.SceneManagement; 6 | using UnityEngine; 7 | using UnityObject = UnityEngine.Object; 8 | 9 | namespace litefeel.Finder.Editor 10 | { 11 | public static class Finder 12 | { 13 | private const string ASSETS_DIR = "Assets/"; 14 | private const string PACKAGE_DIR = "Packages/"; 15 | 16 | 17 | private static List s_TempMats = new List(); 18 | 19 | public static void Progress(Action action, T[] list, string title = "Progress Materials", string content = "{0}/{count}") 20 | { 21 | var count = list.Length; 22 | EditorUtility.DisplayCancelableProgressBar("Progressing", $"0/{count}", 0); 23 | try 24 | { 25 | for (var i = 0; i < count; i++) 26 | { 27 | if(EditorUtility.DisplayCancelableProgressBar("Progressing", list[i].ToString(), i / (float)count)) 28 | return; 29 | action(list[i]); 30 | } 31 | } 32 | finally 33 | { 34 | EditorUtility.ClearProgressBar(); 35 | } 36 | } 37 | 38 | 39 | public static void ForeachMats(Action action, bool showProgress = true, string[] searchInFolders = null) 40 | { 41 | 42 | var guids = AssetDatabase.FindAssets("t:Material", searchInFolders); 43 | var count = guids.Length; 44 | if (showProgress) 45 | EditorUtility.DisplayCancelableProgressBar("Progress Materials", $"0/{count}", 0); 46 | try 47 | { 48 | for (var i = 0; i < count; i++) 49 | { 50 | if (showProgress) 51 | { 52 | if (EditorUtility.DisplayCancelableProgressBar("Progress Prefabs", $"{i}/{count}", i / (float)count)) 53 | break; 54 | } 55 | var matPath = AssetDatabase.GUIDToAssetPath(guids[i]); 56 | if (s_TempMats == null) 57 | s_TempMats = new List(); 58 | s_TempMats.Clear(); 59 | LoadAssetsAtPath(matPath, s_TempMats); 60 | foreach (var mat in s_TempMats) 61 | { 62 | //Debug.Log($"matPath: {matPath}, {mat.name}, {mat.shader.name}", mat); 63 | action(mat, matPath); 64 | } 65 | } 66 | } 67 | finally 68 | { 69 | EditorUtility.ClearProgressBar(); 70 | } 71 | } 72 | 73 | public static void ForeachPrefabs(Action action, bool showProgress, string[] searchInFolders = null) 74 | { 75 | var guids = AssetDatabase.FindAssets("t:Prefab", searchInFolders); 76 | var count = guids.Length; 77 | if (showProgress) 78 | EditorUtility.DisplayCancelableProgressBar("Progress Prefabs", $"0/{count}", 0); 79 | try 80 | { 81 | for (var i = 0; i < count; i++) 82 | { 83 | if (showProgress) 84 | { 85 | if (EditorUtility.DisplayCancelableProgressBar("Progress Prefabs", $"{i}/{count}", i / (float)count)) 86 | break; 87 | } 88 | var path = AssetDatabase.GUIDToAssetPath(guids[i]); 89 | var go = AssetDatabase.LoadAssetAtPath(path); 90 | action(go, path); 91 | } 92 | } 93 | finally 94 | { 95 | EditorUtility.ClearProgressBar(); 96 | } 97 | } 98 | public static void ForeachPrefabAndScene(Action action, bool showProgress, string[] searchInFolders = null, SearchAssetType searchType = SearchAssetType.All) 99 | { 100 | string filter; 101 | switch (searchType) 102 | { 103 | case SearchAssetType.Prefab: filter = "t:Prefab"; break; 104 | case SearchAssetType.Scene: filter = "t:Scene"; break; 105 | default: filter = "t:Prefab t:Scene"; break; 106 | }; 107 | var guids = AssetDatabase.FindAssets(filter, searchInFolders); 108 | var count = guids.Length; 109 | if (showProgress) 110 | EditorUtility.DisplayCancelableProgressBar("Progress Assets", $"0/{count}", 0); 111 | try 112 | { 113 | for (var i = 0; i < count; i++) 114 | { 115 | if (showProgress) 116 | { 117 | if (EditorUtility.DisplayCancelableProgressBar("Progress Assets", $"{i}/{count}", i / (float)count)) 118 | break; 119 | } 120 | var path = AssetDatabase.GUIDToAssetPath(guids[i]); 121 | var go = AssetDatabase.LoadAssetAtPath(path); 122 | action(go, path); 123 | } 124 | } 125 | finally 126 | { 127 | EditorUtility.ClearProgressBar(); 128 | } 129 | } 130 | 131 | public static void ForeachRootGameObjectsInScene(Func action, string scenePath) 132 | { 133 | var sceneCount = EditorSceneManager.sceneCount; 134 | var scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); 135 | if (scene == null) return; 136 | 137 | foreach (var go in scene.GetRootGameObjects()) 138 | { 139 | if (action.Invoke(go)) break; 140 | } 141 | if (EditorSceneManager.sceneCount > sceneCount) 142 | EditorSceneManager.CloseScene(scene, true); 143 | } 144 | 145 | private static void LoadAssetsAtPath(string path, List list) where T : UnityEngine.Object 146 | { 147 | var assets = AssetDatabase.LoadAllAssetsAtPath(path); 148 | foreach (var asset in assets) 149 | { 150 | if (asset is T) 151 | list.Add((T)asset); 152 | } 153 | } 154 | 155 | internal static int FindMaterials(string shaderName, List mats, ShaderType shaderType) 156 | { 157 | var count = mats.Count; 158 | ForeachMats((mat, matPath) => 159 | { 160 | if (shaderName.Equals(mat.shader.name) && GetShaderType(mat.shader).In(shaderType)) 161 | mats.Add(mat); 162 | }); 163 | return mats.Count - count; 164 | } 165 | 166 | internal static int FindMaterials(Shader shader, List mats, string[] searchInFolders) 167 | { 168 | if (shader == null || mats == null) return 0; 169 | var count = mats.Count; 170 | ForeachMats((mat, matPath) => 171 | { 172 | if (mat.shader == shader) 173 | mats.Add(mat); 174 | }, true, searchInFolders); 175 | return mats.Count - count; 176 | } 177 | 178 | static ShaderType GetShaderType(Shader shader) 179 | { 180 | var path = AssetDatabase.GetAssetPath(shader); 181 | if (path.StartsWith(ASSETS_DIR)) 182 | return ShaderType.Project; 183 | if (path.StartsWith(PACKAGE_DIR)) 184 | return ShaderType.Package; 185 | return ShaderType.Builtin; 186 | } 187 | 188 | } 189 | } -------------------------------------------------------------------------------- /Editor/Finder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f34419348824973488d000d9d07fa804 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/IFinderWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | interface IFinderWindow 7 | { 8 | void InitAsset(Object obj); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Editor/IFinderWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c300496a813fe694d98448bb54db5fd4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/MenuItems.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | static class MenuItems 7 | { 8 | [MenuItem("Assets/Finder/Find Missing Script - All Assets", priority = 1000)] 9 | static void FindMissingOnAllAssets() 10 | { 11 | ShowWindow(typeof(FindMissingOnAllAssets)); 12 | } 13 | [MenuItem("Assets/Finder/Find Missing Script - Current Scene", priority = 1000)] 14 | static void FindMissingOnCurrentScene() 15 | { 16 | ShowWindow(typeof(FindMissingOnCurrentScene)); 17 | } 18 | [MenuItem("Assets/Finder/Find Missing Prop - All Assets", priority = 1000)] 19 | static void FindMissingPropertyOnAllAssets() 20 | { 21 | ShowWindow(typeof(FindMissingPropertyOnAllAssets)); 22 | } 23 | [MenuItem("Assets/Finder/Find Missing Prop - Current Scene", priority = 1000)] 24 | static void FindMissingPropertyOnCurrentScene() 25 | { 26 | ShowWindow(typeof(FindMissingPropertyOnCurrentScene)); 27 | } 28 | [MenuItem("Assets/Finder/Find Prefabs By Shader", priority = 1100)] 29 | static void FindPrefabByShader() 30 | { 31 | ShowWindow(); 32 | } 33 | [MenuItem("Assets/Finder/Find Prefabs By Material", priority = 1100)] 34 | static void FindPrefabByMaterial() 35 | { 36 | ShowWindow(); 37 | } 38 | [MenuItem("Assets/Finder/Find Prefabs By Script", priority = 1100)] 39 | static void FindPrefabByScript() 40 | { 41 | ShowWindow(); 42 | } 43 | [MenuItem("Assets/Finder/Find Prefabs By Animation Clip", priority = 1100)] 44 | static void FindPrefabByAnimation() 45 | { 46 | ShowWindow(); 47 | } 48 | [MenuItem("Assets/Finder/Find Prefabs By Textue", priority = 1100)] 49 | static void FindPrefabByTextue() 50 | { 51 | ShowWindow(); 52 | } 53 | [MenuItem("Assets/Finder/Find Prefabs By Sprite", priority = 1100)] 54 | static void FindPrefabBySprite() 55 | { 56 | ShowWindow(); 57 | } 58 | [MenuItem("Assets/Finder/Find Prefabs By Child Name", priority = 1100)] 59 | static void FindPrefabByChildrenName() 60 | { 61 | ShowWindow(typeof(FindPrefabByChildrenName)); 62 | } 63 | [MenuItem("Assets/Finder/Find Materials By Texture", priority = 1200)] 64 | static void FindMaterialByTexture() 65 | { 66 | ShowWindow(); 67 | } 68 | [MenuItem("Assets/Finder/Find Materials By Shader", priority = 1200)] 69 | static void FindMaterialByShader() 70 | { 71 | ShowWindow(); 72 | } 73 | //[MenuItem("Assets/Finder/FindSprite")] 74 | //static void FindSprite() 75 | //{ 76 | // ShowWindow(); 77 | //} 78 | //[MenuItem("Assets/Finder/FindText")] 79 | //static void FindText() 80 | //{ 81 | // ShowWindow(); 82 | //} 83 | //[MenuItem("Assets/Finder/FindFontInPrefab")] 84 | //static void FindFontInPrefab() 85 | //{ 86 | // ShowWindow(); 87 | //} 88 | [MenuItem("Assets/Finder/Find Usage", priority = 1300)] 89 | static void FindUsage() 90 | { 91 | ShowWindow(); 92 | } 93 | [MenuItem("Assets/Finder/Find Usage - Current Scene", priority = 1301)] 94 | static void FindUsageOnCurrentScene() 95 | { 96 | ShowWindow(); 97 | } 98 | 99 | private static void ShowWindow(string title = null) where T : EditorWindow, IFinderWindow 100 | { 101 | if (string.IsNullOrEmpty(title)) 102 | { 103 | title = typeof(T).Name; 104 | } 105 | var window = EditorWindow.GetWindow(); 106 | window.InitAsset(Selection.activeObject); 107 | window.titleContent = new UnityEngine.GUIContent(title); 108 | window.Show(); 109 | } 110 | 111 | private static void ShowWindow(System.Type winType, string title = null) 112 | { 113 | if (string.IsNullOrEmpty(title)) 114 | { 115 | title = winType.Name; 116 | } 117 | var window = EditorWindow.GetWindow(winType); 118 | window.titleContent = new UnityEngine.GUIContent(title); 119 | window.Show(); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Editor/MenuItems.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47deedec236f57d4eb021d139f23db54 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/SearchAssetType.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #if !UNITY_2019_2_OR_NEWER 4 | using InspectorName = System.ComponentModel.DescriptionAttribute; 5 | #endif 6 | namespace litefeel.Finder.Editor 7 | { 8 | public enum SearchAssetType 9 | { 10 | All, 11 | Prefab, 12 | Scene, 13 | } 14 | 15 | public enum SearchAssetFolder 16 | { 17 | Assets, 18 | [InspectorName("Assets + Packages")] 19 | AssetsAndPackages, 20 | Folder, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Editor/SearchAssetType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a85bf09f15193024c955ad6dbf976dd6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace litefeel.Finder.Editor 4 | { 5 | [Flags] 6 | enum ShaderType 7 | { 8 | Project = 1 << 0, 9 | Package = 1 << 1, 10 | Builtin = 1 << 2, 11 | All = Project | Package | Builtin, 12 | } 13 | 14 | static class ShaderTypeExt 15 | { 16 | public static bool In(this ShaderType one, ShaderType all) 17 | { 18 | return (one & all) != 0; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Editor/ShaderType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96b12367d47a414499675a73a7a175c8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7b558458fbd4044b91527cbf0bd2e94 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Utils/EditorGUILayoutUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace litefeel.Finder.Editor 8 | { 9 | static class EditorGUILayoutUtil 10 | { 11 | private static readonly HashSet s_NonObsoleteEnumTypes = new HashSet(); 12 | private static readonly HashSet s_EnumTypes = new HashSet(); 13 | public static Enum EnumPopup(Enum selected, params GUILayoutOption[] options) 14 | { 15 | InitEnumData(selected.GetType(), true); 16 | return EditorGUILayout.EnumPopup(selected, options); 17 | } 18 | 19 | public static Enum EnumPopup(Enum selected, GUIStyle style, params GUILayoutOption[] options) 20 | { 21 | InitEnumData(selected.GetType(), true); 22 | return EditorGUILayout.EnumPopup(selected, style, options); 23 | } 24 | 25 | private static void InitEnumData(Type enumType, bool excludeObsolete = true) 26 | { 27 | #if !UNITY_2019_2_OR_NEWER 28 | var sets = excludeObsolete ? s_NonObsoleteEnumTypes : s_EnumTypes; 29 | if (sets.Contains(enumType)) return; 30 | 31 | sets.Add(enumType); 32 | GetEnumData(enumType, excludeObsolete, out var values, out var displayNames); 33 | 34 | for (var i = 0; i < values.Length; i++) 35 | displayNames[i] = GetDisplayName(values[i]); 36 | #endif 37 | } 38 | #if !UNITY_2019_2_OR_NEWER 39 | private static void GetEnumData(Type enumType, bool excludeObsolete, out Enum[] values, out string[] displayNames) 40 | { 41 | //var EnumDataUtility = Type.GetType("UnityEditor.PopupCallbackInfo"); 42 | var EnumDataUtility = typeof(EditorGUI); 43 | var GetCachedEnumData = EnumDataUtility.GetMethod("GetCachedEnumData", BindingFlags.Static | BindingFlags.NonPublic); 44 | var EnumData = GetCachedEnumData.Invoke(null, new object[] { enumType, excludeObsolete }); 45 | var valuesInfo = EnumData.GetType().GetField("values"); 46 | values = valuesInfo.GetValue(EnumData) as Enum[]; 47 | var displayNamesInfo = EnumData.GetType().GetField("displayNames"); 48 | displayNames = displayNamesInfo.GetValue(EnumData) as string[]; 49 | } 50 | #endif 51 | public static string GetDisplayName(Enum value) 52 | { 53 | var enumStr = value.ToString(); 54 | var arr = value.GetType().GetMember(enumStr); 55 | MemberInfo memberInfo = arr.Length > 0 ? arr[0] : null; 56 | if (memberInfo != null) 57 | { 58 | #if UNITY_2019_2_OR_NEWER 59 | var attribute = memberInfo.GetCustomAttribute(false); 60 | if (attribute != null) 61 | return attribute.displayName; 62 | #else 63 | var attribute = memberInfo.GetCustomAttribute(false); 64 | if (attribute != null) 65 | return attribute.Description; 66 | #endif 67 | } 68 | return enumStr; 69 | } 70 | 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Editor/Utils/EditorGUILayoutUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6fbfe8976ebaa947ba1ebf9dd52ba10 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/EditorUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | static class EditorUtil 9 | { 10 | private static readonly GUIContent s_Text = new GUIContent(); 11 | 12 | internal static GUIContent TempContent(string t) 13 | { 14 | s_Text.image = null; 15 | s_Text.text = t; 16 | s_Text.tooltip = null; 17 | return s_Text; 18 | } 19 | 20 | public static float CalcLabelSize(string label, GUIStyle style = null) 21 | { 22 | return CalcLabelSize(TempContent(label), style); 23 | } 24 | 25 | public static float CalcLabelSize(GUIContent label, GUIStyle style = null) 26 | { 27 | if (style == null) 28 | style = EditorStyles.label; 29 | return style.CalcSize(label).x; 30 | } 31 | 32 | 33 | 34 | static System.Reflection.PropertyInfo m_objectReferenceStringValue; 35 | public static bool IsMissing(SerializedProperty prop) 36 | { 37 | if(m_objectReferenceStringValue == null) 38 | m_objectReferenceStringValue = typeof(SerializedProperty).GetProperty("objectReferenceStringValue", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); 39 | var str = m_objectReferenceStringValue.GetValue(prop) as string; 40 | return str.StartsWith("Missing "); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Editor/Utils/EditorUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2eae1be96d4022f4bb0f33c76f2d466e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/FindUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using UnityEditor; 5 | using UnityEditor.Experimental.SceneManagement; 6 | using UnityEditor.SceneManagement; 7 | using UnityEngine; 8 | using UnityEngine.SceneManagement; 9 | 10 | namespace litefeel.Finder.Editor 11 | { 12 | static class FindUtil 13 | { 14 | private static HashSet s_IgnoreTypes = new HashSet() 15 | { 16 | typeof(Transform), 17 | typeof(RectTransform), 18 | typeof(CanvasGroup), 19 | typeof(CanvasRenderer), 20 | typeof(UnityEngine.UI.Outline), 21 | 22 | }; 23 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 24 | public static bool IgnoreType(Type type) 25 | { 26 | return s_IgnoreTypes.Contains(type); 27 | } 28 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 29 | public static bool IgnoreType(Component obj) 30 | { 31 | return obj != null && s_IgnoreTypes.Contains(obj.GetType()); 32 | } 33 | public static bool InScene(string scenePath, Func InGameObject) 34 | { 35 | bool has = false; 36 | Finder.ForeachRootGameObjectsInScene((go) => 37 | { 38 | if (InGameObject(go)) 39 | { 40 | has = true; 41 | return true; 42 | } 43 | return false; 44 | }, scenePath); 45 | return has; 46 | } 47 | 48 | public static bool InGameObject(GameObject go, Material material) 49 | { 50 | return UnityUtil.AnyOneMaterialAndChildren((mat) => 51 | { 52 | return mat == material; 53 | }, go); 54 | } 55 | public static bool InGameObject(GameObject go, Shader shader) 56 | { 57 | return UnityUtil.AnyOneMaterialAndChildren((mat) => 58 | { 59 | if (mat == null) return false; 60 | return mat.shader == shader; 61 | }, go); 62 | } 63 | 64 | public static bool InGameObject(GameObject go, AudioClip clip) 65 | { 66 | return UnityUtil.AnyOneComponentAndChildren((source) => 67 | { 68 | return source.clip == clip; 69 | }, go.transform); 70 | } 71 | 72 | 73 | public static void FilterCurrentStageOrScene(Func func, List results) 74 | { 75 | var stage = PrefabStageUtility.GetCurrentPrefabStage(); 76 | if (stage != null) 77 | { 78 | using (var scope = ListPoolScope.Create()) 79 | { 80 | stage.prefabContentsRoot.GetComponentsInChildren(true, scope.list); 81 | FilterList(func, scope.list, results); 82 | } 83 | } 84 | else 85 | { 86 | var count = EditorSceneManager.loadedSceneCount; 87 | for (var i = 0; i < count; i++) 88 | FilterScene(EditorSceneManager.GetSceneAt(i), func, results); 89 | 90 | if (Application.isPlaying) 91 | { 92 | // DontDestroyOnLoad Scene 93 | var go = new GameObject(); 94 | go.hideFlags = HideFlags.HideAndDontSave; 95 | GameObject.DontDestroyOnLoad(go); 96 | FilterScene(go.scene, func, results); 97 | GameObject.DestroyImmediate(go); 98 | } 99 | } 100 | } 101 | 102 | public static void FilterScene(Scene scene, Func func, List results) 103 | { 104 | var gos = ListPool.Get(); 105 | var trans = ListPool.Get(); 106 | 107 | scene.GetRootGameObjects(gos); 108 | for (var i = 0; i < gos.Count; i++) 109 | { 110 | trans.Clear(); 111 | gos[i].GetComponentsInChildren(true, trans); 112 | FilterList(func, trans, results); 113 | } 114 | ListPool.Release(trans); 115 | ListPool.Release(gos); 116 | } 117 | 118 | private static void FilterList(Func func, List input, List results) 119 | { 120 | for (var i = 0; i < input.Count; i++) 121 | { 122 | if (func(input[i])) 123 | results.Add(input[i]); 124 | } 125 | } 126 | 127 | #region Check Missing 128 | public static bool CheckMissingScriptOnTransfrom(Transform trans) 129 | { 130 | using (var scope = ListPoolScope.Create()) 131 | { 132 | trans.GetComponents(scope.list); 133 | foreach (var comp in scope.list) 134 | { 135 | if (comp == null) 136 | return true; 137 | } 138 | } 139 | return false; 140 | } 141 | 142 | public static bool CheckMissingPropOnTransfrom(Transform trans) 143 | { 144 | using (var scope = ListPoolScope.Create()) 145 | { 146 | trans.GetComponents(scope.list); 147 | foreach (var comp in scope.list) 148 | { 149 | if (comp && UnityUtil.AnyOneProperty(CheckMissingProp, comp)) 150 | return true; 151 | } 152 | } 153 | return false; 154 | } 155 | 156 | public static bool CheckMissingProp(Component obj) 157 | { 158 | if (obj == null) return false; 159 | var so = new SerializedObject(obj); 160 | so.Update(); 161 | //Debug.Log(obj); 162 | var prop = so.GetIterator(); 163 | return UnityUtil.AnyOneProperty(CheckMissingProp, prop, true); 164 | } 165 | 166 | public static bool CheckMissingProp(SerializedProperty prop) 167 | { 168 | if (prop.propertyType == SerializedPropertyType.ObjectReference 169 | && EditorUtil.IsMissing(prop)) 170 | return true; 171 | 172 | return false; 173 | } 174 | #endregion 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Editor/Utils/FindUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed9618e2e13b2b0478576aae265218e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/ListPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | internal static class ListPool 8 | { 9 | // Object pool to avoid allocations. 10 | private static readonly ObjectPool> s_ListPool = new ObjectPool>(null, Clear); 11 | static void Clear(List l) { l.Clear(); } 12 | 13 | public static List Get() 14 | { 15 | return s_ListPool.Get(); 16 | } 17 | 18 | public static void Release(List toRelease) 19 | { 20 | s_ListPool.Release(toRelease); 21 | } 22 | } 23 | 24 | public struct ListPoolScope : IDisposable 25 | { 26 | private bool m_Disposed; 27 | public readonly List list; 28 | private ListPoolScope(List list) 29 | { 30 | m_Disposed = false; 31 | this.list = list; 32 | } 33 | public void Dispose() 34 | { 35 | if (m_Disposed) 36 | return; 37 | m_Disposed = true; 38 | ListPool.Release(list); 39 | } 40 | 41 | public static ListPoolScope Create() 42 | { 43 | return new ListPoolScope(ListPool.Get()); 44 | } 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Editor/Utils/ListPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd1d3b3a41f34004a9dcc79d7e317ce5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | internal class ObjectPool where T : new() 8 | { 9 | private readonly Stack m_Stack = new Stack(); 10 | private readonly UnityAction m_ActionOnGet; 11 | private readonly UnityAction m_ActionOnRelease; 12 | 13 | public int countAll { get; private set; } 14 | public int countActive { get { return countAll - countInactive; } } 15 | public int countInactive { get { return m_Stack.Count; } } 16 | 17 | public ObjectPool(UnityAction actionOnGet, UnityAction actionOnRelease) 18 | { 19 | m_ActionOnGet = actionOnGet; 20 | m_ActionOnRelease = actionOnRelease; 21 | } 22 | 23 | public T Get() 24 | { 25 | T element; 26 | if (m_Stack.Count == 0) 27 | { 28 | element = new T(); 29 | countAll++; 30 | } 31 | else 32 | { 33 | element = m_Stack.Pop(); 34 | } 35 | if (m_ActionOnGet != null) 36 | m_ActionOnGet(element); 37 | return element; 38 | } 39 | 40 | public void Release(T element) 41 | { 42 | if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element)) 43 | Debug.LogError("Internal error. Trying to destroy object that is already released to pool."); 44 | if (m_ActionOnRelease != null) 45 | m_ActionOnRelease(element); 46 | m_Stack.Push(element); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Editor/Utils/ObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4af21d33c36c04c438d663d0bfd757f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/ReflectionMethodsCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEditor; 5 | 6 | namespace UnityEngine.UI 7 | { 8 | internal class ReflectionMethodsCache 9 | { 10 | public delegate string ToolbarSearchFieldCallback(string text, params GUILayoutOption[] options); 11 | public delegate RaycastHit2D Raycast2DCallback(Vector2 p1, Vector2 p2, float f, int i); 12 | public delegate RaycastHit[] RaycastAllCallback(Ray r, float f, int i); 13 | public delegate RaycastHit2D[] GetRayIntersectionAllCallback(Ray r, float f, int i); 14 | public delegate int GetRayIntersectionAllNonAllocCallback(Ray r, RaycastHit2D[] results, float f, int i); 15 | public delegate int GetRaycastNonAllocCallback(Ray r, RaycastHit[] results, float f, int i); 16 | 17 | // We call Physics.Raycast and Physics2D.Raycast through reflection to avoid creating a hard dependency from 18 | // this class to the Physics/Physics2D modules, which would otherwise make it impossible to make content with UI 19 | // without force-including both modules. 20 | public ReflectionMethodsCache() 21 | { 22 | var methodInfo = typeof(EditorGUILayout).GetMethod("ToolbarSearchField", 23 | BindingFlags.NonPublic | BindingFlags.Static, null, 24 | new[] { typeof(string), typeof(GUILayoutOption[]) }, null); 25 | if (methodInfo != null) 26 | ToolbarSearchField = (ToolbarSearchFieldCallback)Delegate.CreateDelegate(typeof(ToolbarSearchFieldCallback), methodInfo); 27 | 28 | } 29 | 30 | public ToolbarSearchFieldCallback ToolbarSearchField = null; 31 | 32 | private static ReflectionMethodsCache s_ReflectionMethodsCache = null; 33 | 34 | public static ReflectionMethodsCache Singleton 35 | { 36 | get 37 | { 38 | if (s_ReflectionMethodsCache == null) 39 | s_ReflectionMethodsCache = new ReflectionMethodsCache(); 40 | return s_ReflectionMethodsCache; 41 | } 42 | } 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /Editor/Utils/ReflectionMethodsCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0050d4c8a3a06ad4a894fd7db1bf0942 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/SearchableEditorWindowUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEditor; 5 | using static UnityEditor.SearchableEditorWindow; 6 | 7 | namespace litefeel.Finder.Editor 8 | { 9 | static class SearchableEditorWindowUtil 10 | { 11 | static FieldInfo m_SearchableWindows; 12 | static FieldInfo m_HierarchyType; 13 | static MethodInfo m_SetSearchFilter; 14 | 15 | public static void ForEach(Action action, HierarchyType type) 16 | { 17 | foreach (var window in GetSearchableWindows()) 18 | { 19 | if (GetHierarchyType(window) == type) 20 | action(window); 21 | } 22 | } 23 | 24 | public static void SetSearchFilter(this SearchableEditorWindow win, string searchFilter, SearchMode mode) 25 | { 26 | if (m_SetSearchFilter == null) 27 | m_SetSearchFilter = typeof(SearchableEditorWindow).GetMethod("SetSearchFilter", BindingFlags.Instance | BindingFlags.NonPublic); 28 | m_SetSearchFilter.Invoke(win, new object[] { searchFilter, mode, false, false }); 29 | } 30 | private static List GetSearchableWindows() 31 | { 32 | if (m_SearchableWindows == null) 33 | m_SearchableWindows = typeof(SearchableEditorWindow).GetField("searchableWindows", BindingFlags.Static | BindingFlags.NonPublic); 34 | return m_SearchableWindows.GetValue(null) as List; 35 | } 36 | 37 | private static HierarchyType GetHierarchyType(SearchableEditorWindow win) 38 | { 39 | if (m_HierarchyType == null) 40 | m_HierarchyType = typeof(SearchableEditorWindow).GetField("m_HierarchyType", BindingFlags.Instance | BindingFlags.NonPublic); 41 | return (HierarchyType)m_HierarchyType.GetValue(win); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Editor/Utils/SearchableEditorWindowUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9657f3aeea4f6aa47ad2e8aac44437d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/SelectionUtil.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using UnityObject = UnityEngine.Object; 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | public static class SelectionUtil 9 | { 10 | private static Object m_Selected; 11 | 12 | public static void Select(Object obj) 13 | { 14 | if (obj == null) return; 15 | if (obj == m_Selected) return; 16 | m_Selected = obj; 17 | EditorGUIUtility.PingObject(obj); 18 | //Selection.activeObject = obj; 19 | } 20 | 21 | public static void Clear() 22 | { 23 | m_Selected = null; 24 | } 25 | 26 | public static T GetAsset() where T : UnityObject 27 | { 28 | var assets = Selection.GetFiltered(SelectionMode.Assets); 29 | if (assets != null && assets.Length == 1) 30 | return assets[0]; 31 | return null; 32 | } 33 | 34 | public static DefaultAsset GetSelectFolderAsset() 35 | { 36 | var asset = GetAsset(); 37 | if (asset != null) 38 | { 39 | if (Directory.Exists(AssetDatabase.GetAssetPath(asset))) 40 | return asset; 41 | } 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Editor/Utils/SelectionUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec8df9b1e74a63c44a7b2e8b6f449e93 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/TypeCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | static class TypeCache 8 | { 9 | private static List s_TypeList; 10 | private static List s_FullNameList; 11 | private static Dictionary s_NameTypeMap; 12 | private static Dictionary s_FullNameTypeMap; 13 | 14 | public static List GetTypes() 15 | { 16 | Init(); 17 | return s_TypeList; 18 | } 19 | public static List GetFullNames() 20 | { 21 | Init(); 22 | return s_FullNameList; 23 | } 24 | public static Type FindType(string fullnameOrName) 25 | { 26 | if (string.IsNullOrEmpty(fullnameOrName)) 27 | return null; 28 | 29 | Init(); 30 | Type type; 31 | if (s_FullNameTypeMap.TryGetValue(fullnameOrName, out type)) 32 | return type; 33 | 34 | s_NameTypeMap.TryGetValue(fullnameOrName, out type); 35 | return type; 36 | } 37 | public static Type GetTypeByFullName(string fullname) 38 | { 39 | if (string.IsNullOrEmpty(fullname)) 40 | return null; 41 | Init(); 42 | s_FullNameTypeMap.TryGetValue(fullname, out var type); 43 | return type; 44 | } 45 | 46 | public static Type GetTypeByName(string name) 47 | { 48 | if (string.IsNullOrEmpty(name)) 49 | return null; 50 | Init(); 51 | s_NameTypeMap.TryGetValue(name, out var type); 52 | return type; 53 | } 54 | 55 | private static void Init() 56 | { 57 | if (s_TypeList != null && s_FullNameList != null) return; 58 | 59 | s_TypeList = new List(); 60 | s_FullNameList = new List(); 61 | s_NameTypeMap = new Dictionary(); 62 | s_FullNameTypeMap = new Dictionary(); 63 | 64 | 65 | var typeSet = new HashSet(); 66 | var nameSet = new HashSet(); 67 | var compType = typeof(Component); 68 | foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies()) 69 | { 70 | var assemblyName = assembly.GetName().FullName; 71 | if (assemblyName == "UnityEditor" || assemblyName.StartsWith("UnityEditor.") || 72 | assemblyName == "System" || assemblyName.StartsWith("System.") || 73 | assemblyName == "mscorlib" || assemblyName.StartsWith("Microsoft.")) 74 | continue; 75 | foreach (var type in assembly.GetTypes()) 76 | { 77 | if (type == compType) 78 | continue; 79 | if (compType.IsAssignableFrom(type) && !typeSet.Contains(type)) 80 | { 81 | var fullname = type.FullName; 82 | var name = type.Name; 83 | 84 | typeSet.Add(type); 85 | s_TypeList.Add(type); 86 | s_FullNameList.Add(fullname); 87 | s_FullNameTypeMap.Add(fullname, type); 88 | 89 | if (nameSet.Add(name)) 90 | s_NameTypeMap.Add(name, type); 91 | else 92 | s_NameTypeMap.Remove(name); 93 | } 94 | } 95 | } 96 | 97 | //Debug.LogError(string.Join("\n", s_NameList)); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Editor/Utils/TypeCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77892bea7c91932468bb40bf3d869417 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Utils/UnityUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | public static class UnityUtil 8 | { 9 | 10 | public static string GetFullPath(Transform trans) 11 | { 12 | var list = ListPool.Get(); 13 | while (trans != null) 14 | { 15 | list.Add(trans.name); 16 | trans = trans.parent; 17 | } 18 | list.Reverse(); 19 | var fullpath = string.Join("/", list); 20 | ListPool.Release(list); 21 | return fullpath; 22 | } 23 | public static bool AnyOneMaterialAndChildren(Func func, GameObject go) 24 | { 25 | return AnyOneComponentAndChildren((renderer) => 26 | { 27 | var sharedMaterials = renderer.sharedMaterials; 28 | if (sharedMaterials == null) return false; 29 | foreach (var mat in sharedMaterials) 30 | { 31 | if (func(mat)) 32 | return true; 33 | } 34 | return false; 35 | }, go.transform); 36 | } 37 | public static bool AnyOneProperty(Func func, UnityEngine.Object obj) 38 | { 39 | if (obj == null) return false; 40 | var so = new SerializedObject(obj); 41 | so.Update(); 42 | //Debug.Log(obj); 43 | var prop = so.GetIterator(); 44 | return AnyOneProperty(func, prop, true); 45 | } 46 | public static bool AnyOneProperty(Func func, SerializedProperty prop, bool isFirst) 47 | { 48 | bool expanded = true; 49 | SerializedProperty end = null; 50 | if (!isFirst) 51 | end = prop.GetEndProperty(); 52 | while (prop.NextVisible(expanded)) 53 | { 54 | expanded = false; 55 | if (!isFirst && SerializedProperty.EqualContents(prop, end)) 56 | return false; 57 | var propType = prop.propertyType; 58 | //Debug.Log(prop.propertyPath); 59 | if (propType != SerializedPropertyType.ObjectReference && 60 | propType != SerializedPropertyType.Generic) 61 | continue; 62 | if (func(prop)) 63 | return true; 64 | 65 | if (AnyOneProperty(func, prop.Copy(), false)) 66 | return true; 67 | 68 | } 69 | return false; 70 | } 71 | 72 | public static bool AnyOneTransformAndChildren(Func func, Transform root) 73 | { 74 | if (func(root)) return true; 75 | 76 | var count = root.childCount; 77 | for (var i = 0; i < count; i++) 78 | { 79 | if (AnyOneTransformAndChildren(func, root.GetChild(i))) 80 | return true; 81 | } 82 | return false; 83 | } 84 | 85 | public static bool AnyOneComponent(Func func, Transform root) 86 | where T : Component 87 | { 88 | using (var scope = ListPoolScope.Create()) 89 | { 90 | root.GetComponents(scope.list); 91 | for (var i = 0; i < scope.list.Count; i++) 92 | { 93 | if (func(scope.list[i])) 94 | return true; 95 | } 96 | } 97 | return false; 98 | } 99 | 100 | public static bool AnyOneComponentAndChildren(Func func, Transform root) 101 | where T : Component 102 | { 103 | using (var scope = ListPoolScope.Create()) 104 | { 105 | root.GetComponentsInChildren(scope.list); 106 | for (var i = 0; i < scope.list.Count; i++) 107 | { 108 | if (func(scope.list[i])) 109 | return true; 110 | } 111 | } 112 | return false; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Editor/Utils/UnityUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 256e6e6ffe7dbd940a6432683ee6f12f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87c2370a7aa50464ca1bb9e62519bb96 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Windows/FindFontInPrefab.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEditor.Experimental.SceneManagement; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | namespace litefeel.Finder.Editor 8 | { 9 | class FindFontInPrefab : FindAssetWindowBase 10 | { 11 | protected override void OnGUIBody() 12 | { 13 | m_IgnoreSearchAssetFolder = true; 14 | base.OnGUIBody(); 15 | m_DisableFind = m_Asset == null; 16 | } 17 | 18 | protected override void OnGUISearchAssetFolder() 19 | { 20 | } 21 | 22 | protected override void DoFind() 23 | { 24 | var prefabStage = PrefabStageUtility.GetCurrentPrefabStage(); 25 | if (prefabStage == null) return; 26 | 27 | var texts = new List(); 28 | prefabStage.prefabContentsRoot.GetComponentsInChildren(true, texts); 29 | 30 | m_Items.Clear(); 31 | foreach(var txt in texts) 32 | { 33 | if (txt.font == m_Asset) 34 | m_Items.Add(txt); 35 | } 36 | 37 | FillMatNames(m_Items); 38 | } 39 | 40 | private void FillMatNames(List mats) 41 | { 42 | m_ItemNames.Clear(); 43 | 44 | for (var i = 0; i < mats.Count; i++) 45 | { 46 | m_ItemNames.Add(mats[i].name); 47 | } 48 | } 49 | 50 | protected override bool InGameObjectAndChildren(GameObject prefab) 51 | { 52 | throw new System.NotImplementedException(); 53 | } 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Editor/Windows/FindFontInPrefab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c593dde467ae1fb47901a9f38f6a1a7a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMaterialByShader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | class FindMaterialByShader : FindAssetWindowBase 8 | { 9 | protected override void ConfigValues() 10 | { 11 | m_DisableFind = m_Asset == null; 12 | m_IgnoreScearchAssetType = true; 13 | } 14 | 15 | protected override void DoFind() 16 | { 17 | m_Items.Clear(); 18 | Finder.FindMaterials(m_Asset, m_Items, GetSearchInFolders()); 19 | FillMatNames(m_Items); 20 | m_SimpleTreeView.Reload(); 21 | } 22 | 23 | private void FillMatNames(List mats) 24 | { 25 | m_ItemNames.Clear(); 26 | 27 | for (var i = 0; i < mats.Count; i++) 28 | { 29 | var path = AssetDatabase.GetAssetPath(mats[i]); 30 | if (!path.EndsWith(".mat")) 31 | path += $"/{mats[i].name}.mat"; 32 | m_ItemNames.Add(path); 33 | } 34 | } 35 | protected override bool InGameObjectAndChildren(GameObject prefab) 36 | { 37 | throw new System.NotImplementedException(); 38 | } 39 | protected override void OnItemDoubleClick(int index) 40 | { 41 | Selection.activeObject = m_Items[index]; 42 | } 43 | 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Editor/Windows/FindMaterialByShader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dbae62be7085324d8393406da14ba9b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMaterialByTexture.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | class FindMaterialByTexture : FindAssetWindowBase 8 | { 9 | protected override void ConfigValues() 10 | { 11 | m_DisableFind = m_Asset == null; 12 | m_IgnoreScearchAssetType = true; 13 | } 14 | 15 | protected override void DoFind() 16 | { 17 | m_Items.Clear(); 18 | Finder.ForeachMats((mat, matPath) => 19 | { 20 | if (InMaterial(mat, m_Asset)) 21 | m_Items.Add(mat); 22 | }, true, GetSearchInFolders()); 23 | FillMatNames(m_Items); 24 | m_SimpleTreeView.Reload(); 25 | } 26 | 27 | private bool InMaterial(Material mat, Texture tex) 28 | { 29 | return UnityUtil.AnyOneProperty((prop) => 30 | { 31 | return prop.propertyType == SerializedPropertyType.ObjectReference 32 | && prop.objectReferenceValue == tex; 33 | }, mat); 34 | } 35 | 36 | private void FillMatNames(List mats) 37 | { 38 | m_ItemNames.Clear(); 39 | 40 | for (var i = 0; i < mats.Count; i++) 41 | { 42 | var path = AssetDatabase.GetAssetPath(mats[i]); 43 | if (!path.EndsWith(".mat")) 44 | path += $"/{mats[i].name}.mat"; 45 | m_ItemNames.Add(path); 46 | } 47 | } 48 | protected override bool InGameObjectAndChildren(GameObject prefab) 49 | { 50 | throw new System.NotImplementedException(); 51 | } 52 | protected override void OnItemDoubleClick(int index) 53 | { 54 | Selection.activeObject = m_Items[index]; 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Editor/Windows/FindMaterialByTexture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14ab6422d64400344af180969f874c51 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingOnAllAssets.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityObject = UnityEngine.Object; 4 | 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | using static UnityUtil; 9 | class FindMissingOnAllAssets : FindWindowBase 10 | { 11 | protected override bool InGameObjectAndChildren(GameObject prefab) 12 | { 13 | return AnyOneComponentAndChildren(comp => 14 | { 15 | return comp == null; 16 | }, prefab.transform); 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingOnAllAssets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c06a4677b68a1934597636d3b37e9853 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingOnCurrentScene.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | class FindMissingOnCurrentScene : FindWindowBase 8 | { 9 | protected override void ConfigValues() 10 | { 11 | m_IgnoreScearchAssetType = true; 12 | m_IgnoreSearchAssetFolder = true; 13 | } 14 | protected override void DoFind() 15 | { 16 | m_Items.Clear(); 17 | m_ItemNames.Clear(); 18 | 19 | FindUtil.FilterCurrentStageOrScene(FindUtil.CheckMissingScriptOnTransfrom, m_Items); 20 | 21 | foreach (var item in m_Items) 22 | { 23 | m_ItemNames.Add(UnityUtil.GetFullPath(item)); 24 | } 25 | 26 | m_SimpleTreeView.Reload(); 27 | } 28 | 29 | protected override bool InGameObjectAndChildren(GameObject prefab) { return false; } 30 | 31 | protected override void OnItemDoubleClick(int index) 32 | { 33 | Selection.activeTransform = m_Items[index]; 34 | } 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingOnCurrentScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64ec4d2cdaae92e4d94fd1e0fd18c198 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingPropertyOnAllAssets.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityObject = UnityEngine.Object; 4 | 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | class FindMissingPropertyOnAllAssets : FindWindowBase 9 | { 10 | protected override bool InGameObjectAndChildren(GameObject prefab) 11 | { 12 | return UnityUtil.AnyOneComponentAndChildren(FindUtil.CheckMissingProp, prefab.transform); 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingPropertyOnAllAssets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94762f1527accc746b921aacda6f5eb8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingPropertyOnCurrentScene.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | 5 | namespace litefeel.Finder.Editor 6 | { 7 | class FindMissingPropertyOnCurrentScene : FindWindowBase 8 | { 9 | protected override void ConfigValues() 10 | { 11 | m_IgnoreScearchAssetType = true; 12 | m_IgnoreSearchAssetFolder = true; 13 | } 14 | protected override void DoFind() 15 | { 16 | m_Items.Clear(); 17 | m_ItemNames.Clear(); 18 | 19 | FindUtil.FilterCurrentStageOrScene(FindUtil.CheckMissingPropOnTransfrom, m_Items); 20 | 21 | foreach (var item in m_Items) 22 | { 23 | m_ItemNames.Add(UnityUtil.GetFullPath(item)); 24 | } 25 | 26 | m_SimpleTreeView.Reload(); 27 | } 28 | 29 | protected override bool InGameObjectAndChildren(GameObject prefab) { return false; } 30 | 31 | protected override void OnItemDoubleClick(int index) 32 | { 33 | Selection.activeTransform = m_Items[index]; 34 | } 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Editor/Windows/FindMissingPropertyOnCurrentScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 087ca2e05a699de448c30ec2716ba7ab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByAnimation.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabByAnimation : FindAssetWindowBase 7 | { 8 | 9 | protected override void ConfigValues() 10 | { 11 | m_DisableFind = m_Asset == null; 12 | m_EnabledFindInScene = m_Asset != null; 13 | } 14 | 15 | protected override bool InGameObjectAndChildren(GameObject prefab) 16 | { 17 | var has = UnityUtil.AnyOneComponentAndChildren((animator) => 18 | { 19 | if (!animator.runtimeAnimatorController) return false; 20 | foreach (var clip in animator.runtimeAnimatorController.animationClips) 21 | { 22 | if (clip == m_Asset) 23 | return true; 24 | } 25 | return false; 26 | }, prefab.transform); 27 | has |= UnityUtil.AnyOneComponentAndChildren((animation) => 28 | { 29 | foreach (var clip in AnimationUtility.GetAnimationClips(animation.gameObject)) 30 | { 31 | if (clip == m_Asset) 32 | return true; 33 | } 34 | return false; 35 | }, prefab.transform); 36 | return has; 37 | } 38 | 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByAnimation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b06c899f5aa36f48aa0edc1a8a59d8e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByAudio.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabByAudio : FindAssetWindowBase 7 | { 8 | 9 | protected override void ConfigValues() 10 | { 11 | m_DisableFind = m_Asset == null; 12 | m_EnabledFindInScene = m_Asset != null; 13 | } 14 | 15 | protected override bool InGameObjectAndChildren(GameObject prefab) 16 | { 17 | return FindUtil.InGameObject(prefab, m_Asset); 18 | } 19 | 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByAudio.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe162fc27d7883147877ecccf75c55b7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByChildrenName.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabByChildrenName : FindWindowBase 7 | { 8 | protected string m_ChildName; 9 | protected bool m_EnabledFindInScene; 10 | 11 | protected override void ConfigValues() 12 | { 13 | m_EnabledFindInScene = !string.IsNullOrEmpty(m_ChildName); 14 | } 15 | 16 | protected override void OnGUIBody() 17 | { 18 | EditorGUILayout.BeginHorizontal(); 19 | { 20 | m_ChildName = EditorGUILayout.TextField(m_ChildName); 21 | OnGUIFindInScene(); 22 | } 23 | EditorGUILayout.EndHorizontal(); 24 | 25 | base.OnGUIBody(); 26 | } 27 | 28 | protected virtual void OnGUIFindInScene() 29 | { 30 | if (m_EnabledFindInScene) 31 | { 32 | if (GUILayout.Button("FindInScene", GUILayout.ExpandWidth(false))) 33 | OnClickFindInScene(); 34 | } 35 | } 36 | 37 | protected virtual void OnClickFindInScene() 38 | { 39 | SearchableEditorWindowUtil.ForEach((win) => 40 | { 41 | win.SetSearchFilter(m_ChildName, SearchableEditorWindow.SearchMode.All); 42 | }, HierarchyType.GameObjects); 43 | } 44 | 45 | protected override bool InGameObjectAndChildren(GameObject prefab) 46 | { 47 | return UnityUtil.AnyOneTransformAndChildren((trans) => 48 | { 49 | return trans.name.Contains(m_ChildName); 50 | }, prefab.transform); 51 | } 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByChildrenName.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc4eefccf8b3c1a40a3abd8198a00f4d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByMaterial.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabByMaterial : FindAssetWindowBase 7 | { 8 | protected override void ConfigValues() 9 | { 10 | m_DisableFind = m_Asset == null; 11 | m_EnabledFindInScene = m_Asset != null; 12 | } 13 | 14 | protected override bool InGameObjectAndChildren(GameObject prefab) 15 | { 16 | return FindUtil.InGameObject(prefab, m_Asset); 17 | } 18 | 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByMaterial.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 779dee94f497ae449a2cdc67fb240b12 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditorInternal; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | namespace litefeel.Finder.Editor 8 | { 9 | class FindPrefabByScript : FindAssetWindowBase 10 | { 11 | private System.Type m_ScriptType; 12 | private string m_ScriptFullName; 13 | 14 | public override void InitAsset(UnityEngine.Object obj) 15 | { 16 | base.InitAsset(obj); 17 | if(m_Asset == null) 18 | { 19 | m_Asset = SelectionUtil.GetAsset(); 20 | } 21 | if(m_Asset == null) 22 | { 23 | m_Folder = SelectionUtil.GetSelectFolderAsset(); 24 | } 25 | } 26 | 27 | protected override void ConfigValues() 28 | { 29 | m_Message = null; 30 | if (m_Asset != null) 31 | { 32 | m_ScriptType = m_Asset.GetClass(); 33 | if (!typeof(Component).IsAssignableFrom(m_ScriptType)) 34 | { 35 | m_ScriptFullName = null; 36 | m_Message = "Script must be inherit from UnityEngine.Component"; 37 | } 38 | else 39 | m_ScriptFullName = m_ScriptType.FullName; 40 | } 41 | m_ScriptType = TypeCache.FindType(m_ScriptFullName); 42 | 43 | m_DisableFind = m_ScriptType == null; 44 | m_EnabledFindInScene = m_ScriptType != null; 45 | } 46 | 47 | protected override void OnBeforeAssetUI() 48 | { 49 | EditorGUI.BeginChangeCheck(); 50 | m_ScriptFullName = EditorGUILayout.DelayedTextField(m_ScriptFullName); 51 | if(EditorGUI.EndChangeCheck()) 52 | { 53 | m_ScriptType = TypeCache.FindType(m_ScriptFullName); 54 | m_Asset = null; 55 | } 56 | } 57 | 58 | protected override bool InGameObjectAndChildren(GameObject prefab) 59 | { 60 | return prefab.GetComponentInChildren(m_ScriptType, true); 61 | } 62 | 63 | protected override string GetFindInSceneSearchFilter(ref SearchableEditorWindow.SearchMode searchMode) 64 | { 65 | if (m_Asset != null) 66 | return $"t:{m_ScriptType.FullName}"; 67 | else 68 | { 69 | searchMode = SearchableEditorWindow.SearchMode.Type; 70 | return m_ScriptType.Name; 71 | } 72 | } 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3971ecb1142dd4d438c4afcd00bcfec0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByShader.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace litefeel.Finder.Editor 4 | { 5 | class FindPrefabByShader : FindAssetWindowBase 6 | { 7 | protected override void ConfigValues() 8 | { 9 | m_DisableFind = m_Asset == null; 10 | m_EnabledFindInScene = m_Asset != null; 11 | } 12 | 13 | protected override bool InGameObjectAndChildren(GameObject prefab) 14 | { 15 | return FindUtil.InGameObject(prefab, m_Asset); 16 | } 17 | 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByShader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77b1952d7f151d346baa1ccb35c5b547 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabBySprite.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabBySprite : FindAssetWindowBase 7 | { 8 | protected override void ConfigValues() 9 | { 10 | m_DisableFind = m_Asset == null; 11 | m_EnabledFindInScene = m_Asset != null; 12 | } 13 | 14 | protected override bool InGameObjectAndChildren(GameObject prefab) 15 | { 16 | return UnityUtil.AnyOneComponentAndChildren((comp) => 17 | { 18 | if (FindUtil.IgnoreType(comp)) return false; 19 | return UnityUtil.AnyOneProperty((prop) => 20 | { 21 | return prop.propertyType == SerializedPropertyType.ObjectReference && 22 | prop.objectReferenceValue == m_Asset; 23 | 24 | }, comp); 25 | }, prefab.transform); 26 | } 27 | 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabBySprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf5251a9fe1d45841988f956fc0d1b86 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByTextue.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindPrefabByTextue : FindAssetWindowBase 7 | { 8 | protected override void ConfigValues() 9 | { 10 | m_DisableFind = m_Asset == null; 11 | m_EnabledFindInScene = m_Asset != null; 12 | } 13 | 14 | protected override bool InGameObjectAndChildren(GameObject prefab) 15 | { 16 | return UnityUtil.AnyOneComponentAndChildren((comp) => 17 | { 18 | if (FindUtil.IgnoreType(comp)) return false; 19 | return UnityUtil.AnyOneProperty((prop) => 20 | { 21 | return prop.propertyType == SerializedPropertyType.ObjectReference && 22 | prop.objectReferenceValue == m_Asset; 23 | 24 | }, comp); 25 | }, prefab.transform); 26 | } 27 | 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Editor/Windows/FindPrefabByTextue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a858a776ced46a0439a5de8b98576a81 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindSprite.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | class FindSprite : FindAssetWindowBase 9 | { 10 | protected override void OnGUIBody() 11 | { 12 | base.OnGUIBody(); 13 | m_DisableFind = m_Asset == null; 14 | } 15 | 16 | 17 | private List m_Images = new List(); 18 | protected override void DoFind() 19 | { 20 | m_Items.Clear(); 21 | Finder.ForeachPrefabs((prefab, path) => 22 | { 23 | m_Images.Clear(); 24 | prefab.GetComponentsInChildren(true, m_Images); 25 | foreach (var img in m_Images) 26 | { 27 | Debug.Log($"Sprite {path}, {GetName(img.sprite)}, {GetName(img.overrideSprite)}", img); 28 | if (img.sprite == m_Asset || img.overrideSprite == m_Asset) 29 | { 30 | m_Items.Add(prefab); 31 | break; 32 | } 33 | } 34 | }, true, GetSearchInFolders()); 35 | FillMatNames(m_Items); 36 | } 37 | 38 | private string GetName(Object obj) 39 | { 40 | if (obj != null) return obj.name; 41 | return null; 42 | } 43 | 44 | private void FillMatNames(List mats) 45 | { 46 | m_ItemNames.Clear(); 47 | for (var i = 0; i < mats.Count; i++) 48 | { 49 | var path = AssetDatabase.GetAssetPath(mats[i]); 50 | //if (!path.EndsWith(".mat")) 51 | // path += ".mat"; 52 | m_ItemNames.Add(path); 53 | } 54 | } 55 | 56 | protected override bool InGameObjectAndChildren(GameObject prefab) 57 | { 58 | throw new System.NotImplementedException(); 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Editor/Windows/FindSprite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f418284158b8a3848add2248ecf79301 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindText.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | class FindText : FindAssetWindowBase 9 | { 10 | 11 | protected override void DoFind() 12 | { 13 | m_Items.Clear(); 14 | var texts = new List(); 15 | 16 | Finder.ForeachPrefabs((go, path)=> { 17 | texts.Clear(); 18 | go.GetComponentsInChildren(true, texts); 19 | if (texts.Count > 0) 20 | m_Items.Add(go); 21 | }, true, GetSearchInFolders()); 22 | FillMatNames(m_Items); 23 | } 24 | 25 | protected override bool InGameObjectAndChildren(GameObject prefab) 26 | { 27 | throw new System.NotImplementedException(); 28 | } 29 | 30 | private void FillMatNames(List mats) 31 | { 32 | m_ItemNames.Clear(); 33 | for (var i = 0; i < mats.Count; i++) 34 | { 35 | m_ItemNames.Add(AssetDatabase.GetAssetPath(mats[i])); 36 | } 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Editor/Windows/FindText.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7431b1eedbbf15a47a4c56b7f7f5016b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindUsage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace litefeel.Finder.Editor 7 | { 8 | class FindUsage : FindAssetWindowBase 9 | { 10 | readonly Type m_UnityObjectType = typeof(UnityEngine.Object); 11 | protected override void ConfigValues() 12 | { 13 | m_DisableFind = m_Asset == null; 14 | m_EnabledFindInScene = m_Asset != null; 15 | } 16 | 17 | protected override void DoFind() 18 | { 19 | m_Items.Clear(); 20 | m_ItemNames.Clear(); 21 | var time = DateTime.Now; 22 | var paths = AssetDatabase.GetAllAssetPaths(); 23 | var list = GetSearchInFolders(); 24 | if(list.Length > 0) 25 | { 26 | string prefix = list[0]; 27 | var tmp = new List(paths); 28 | tmp.RemoveAll((f) => !f.StartsWith(prefix)); 29 | paths = tmp.ToArray(); 30 | } 31 | //paths = new string[] { "Assets/Art/FBmap/Materials/7.mat", "Assets/BuildOnlyAssets/FX/Materials/Eagle_high_fx.mat" }; 32 | Finder.Progress((path) => 33 | { 34 | var ext = System.IO.Path.GetExtension(path); 35 | switch (ext.ToLower()) 36 | { 37 | case ".cs": return; 38 | case ".unity": 39 | if (FindUtil.InScene(path, InGameObjectAndChildren)) 40 | { 41 | m_Items.Add(AssetDatabase.LoadAssetAtPath(path)); 42 | } 43 | return; 44 | } 45 | //Debug.Log(ext + " " + path); 46 | var assets = AssetDatabase.LoadAllAssetsAtPath(path); 47 | foreach (var asset in assets) 48 | { 49 | // asset is null when missing script 50 | if (asset == null) continue; 51 | if (asset == m_Asset) continue; 52 | if (asset.GetType() == m_UnityObjectType) 53 | { 54 | // UnityObject cannot contain other asset 55 | continue; 56 | //Debug.Log($"{asset}, {asset.GetType()}, {asset.name}, {path}"); 57 | // Ignore Deprecated EditorExtensionImpl 58 | //if (asset.name == "Deprecated EditorExtensionImpl") 59 | // continue; 60 | } 61 | 62 | if (InAsset(asset, path)) 63 | m_Items.Add(asset); 64 | } 65 | }, paths); 66 | Debug.Log(DateTime.Now - time); 67 | m_ItemNames.Clear(); 68 | foreach (var item in m_Items) 69 | m_ItemNames.Add(AssetDatabase.GetAssetPath(item)); 70 | m_SimpleTreeView.Reload(); 71 | } 72 | 73 | private bool InAsset(UnityEngine.Object asset, string path) 74 | { 75 | switch (asset) 76 | { 77 | case GameObject go: 78 | return InGameObjectAndChildren(go); 79 | case SceneAsset scene: 80 | return FindUtil.InScene(path, InGameObjectAndChildren); 81 | default: 82 | return UnityUtil.AnyOneProperty((prop) => 83 | { 84 | return prop.propertyType == SerializedPropertyType.ObjectReference && 85 | prop.objectReferenceValue == m_Asset; 86 | 87 | }, asset); 88 | } 89 | } 90 | 91 | protected override bool InGameObjectAndChildren(GameObject prefab) 92 | { 93 | return UnityUtil.AnyOneComponentAndChildren((comp) => 94 | { 95 | if (FindUtil.IgnoreType(comp)) return false; 96 | return UnityUtil.AnyOneProperty((prop) => 97 | { 98 | return prop.propertyType == SerializedPropertyType.ObjectReference && 99 | prop.objectReferenceValue == m_Asset; 100 | 101 | }, comp); 102 | }, prefab.transform); 103 | } 104 | 105 | protected override void OnItemDoubleClick(int index) 106 | { 107 | AssetDatabase.OpenAsset(m_Items[index]); 108 | } 109 | } 110 | } 111 | 112 | -------------------------------------------------------------------------------- /Editor/Windows/FindUsage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a130016ba33cbea48afe117d6dd1eabd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Windows/FindUsageOnCurrentScene.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace litefeel.Finder.Editor 5 | { 6 | class FindUsageOnCurrentScene : FindAssetWindowBase 7 | { 8 | protected override void ConfigValues() 9 | { 10 | m_DisableFind = m_Asset == null; 11 | m_EnabledFindInScene = false; 12 | m_IgnoreSearchAssetFolder = true; 13 | m_IgnoreScearchAssetType = true; 14 | } 15 | 16 | protected override void DoFind() 17 | { 18 | m_Items.Clear(); 19 | m_ItemNames.Clear(); 20 | 21 | FindUtil.FilterCurrentStageOrScene(InGameObjectAndChildren, m_Items); 22 | 23 | foreach (var item in m_Items) 24 | { 25 | m_ItemNames.Add(UnityUtil.GetFullPath(item)); 26 | } 27 | 28 | m_SimpleTreeView.Reload(); 29 | } 30 | 31 | protected override bool InGameObjectAndChildren(GameObject prefab) 32 | { 33 | return InGameObjectAndChildren(prefab.transform); 34 | } 35 | 36 | protected bool InGameObjectAndChildren(Transform prefab) 37 | { 38 | return UnityUtil.AnyOneComponent((comp) => 39 | { 40 | if (FindUtil.IgnoreType(comp)) return false; 41 | return UnityUtil.AnyOneProperty((prop) => 42 | { 43 | return prop.propertyType == SerializedPropertyType.ObjectReference && 44 | prop.objectReferenceValue == m_Asset; 45 | 46 | }, comp); 47 | }, prefab); 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Editor/Windows/FindUsageOnCurrentScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64dda6c284964714db59f96521397476 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/com.litefeel.Finder.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.litefeel.Finder.Editor", 3 | "references": [], 4 | "optionalUnityReferences": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [] 14 | } -------------------------------------------------------------------------------- /Editor/com.litefeel.Finder.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c14f23a1ef54c734f9f1591b076df233 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 litefeel.com 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.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a94f84eace1096c449dfbb923273bafd 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Finder 2 | 3 | [![Test](https://github.com/litefeel/Unity-Finder/workflows/Test/badge.svg)](https://github.com/litefeel/Unity-Finder/actions) 4 | [![](https://img.shields.io/github/release/litefeel/Unity-Finder.svg?label=latest%20version)](https://github.com/litefeel/Unity-Finder/releases) 5 | [![](https://img.shields.io/github/license/litefeel/Unity-Finder.svg)](https://github.com/litefeel/Unity-Finder/blob/master/LICENSE.md) 6 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/litefeel) 7 | 8 | Find Asset in Unity. 9 | 10 | 11 | #### Shotscreen 12 | 13 | ![shotscreen](Documentation~/shotscreen1.png) 14 | 15 | 16 | ### Requirement 17 | 18 | - Unity 2018.4+ 19 | 20 | ### Install 21 | 22 | - By NPM (Ease upgrade in Package Manager UI)**Recommend** 23 | 24 | Find the manifest.json file in the Packages folder of your project and edit it to look like this: 25 | ``` js 26 | { 27 | "scopedRegistries": [ 28 | { 29 | "name": "My Registry", 30 | "url": "https://registry.npmjs.org", 31 | "scopes": [ 32 | "com.litefeel" 33 | ] 34 | } 35 | ], 36 | "dependencies": { 37 | "com.litefeel.finder": "1.1.0", 38 | ... 39 | } 40 | } 41 | ``` 42 | 43 | - By git url 44 | 45 | Find the manifest.json file in the Packages folder of your project and edit it to look like this: 46 | ``` js 47 | { 48 | "dependencies": { 49 | "com.litefeel.finder": "https://github.com/litefeel/Unity-Finder.git#1.1.0", 50 | ... 51 | } 52 | } 53 | ``` 54 | 55 | 56 | ### Support 57 | 58 | * Create issues by issues page (https://github.com/litefeel/Unity-Finder/issues) 59 | * Send email to me: litefeel@gmail.com 60 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 713a2d94d3645904d82ded013ad08fe8 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.litefeel.finder", 3 | "displayName": "Finder", 4 | "version": "1.1.0", 5 | "unity": "2018.4", 6 | "description": "Find Asset in Unity", 7 | "keywords": [ 8 | "Editor", 9 | "Open", 10 | "File", 11 | "Default", 12 | "Application" 13 | ], 14 | "author": { 15 | "name": "litefeel", 16 | "email": "litefeel@gmial.com", 17 | "url": "https://www.litefeel.com" 18 | }, 19 | "category": "Tools", 20 | "type": "tool", 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/litefeel/Unity-Finder.git" 24 | }, 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/litefeel/Unity-Finder/issues" 28 | }, 29 | "homepage": "https://github.com/litefeel/Unity-Finder#readme" 30 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 165031e9771986744802f835a720cab0 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------