static void Init() { // Get existing open window or if none, make a new one: FindReferencesInProject window = (FindReferencesInProject)EditorWindow.GetWindow(typeof(FindReferencesInProject)); window.Show(); if (Selection.activeObject != null && AssetDatabase.IsMainAsset(Selection.activeObject)) { window.objectToExamine = Selection.activeObject; } }
public static void DeleteBullet() { GameObject selectedObj = Selection.activeObject as GameObject; if (selectedObj == null) { return; } string assetPath = AssetDatabase.GetAssetPath(selectedObj); Object[] roots = new Object[] { selectedObj }; Object[] objs = EditorUtility.CollectDependencies(roots); List <string> assetPaths = new List <string>(); foreach (Object obj in objs) { string path = AssetDatabase.GetAssetPath(obj); if (!assetPaths.Contains(path) && path != assetPath) { assetPaths.Add(path); } } List <string> deleteList = new List <string>() { assetPath }; Dictionary <string, List <string> > referenceCache = new Dictionary <string, List <string> >(); foreach (string depPath in assetPaths) { if (depPath.EndsWith(".cs")) { continue; } Object obj = AssetDatabase.LoadAssetAtPath(depPath, typeof(Object)); if (obj == null) { continue; } List <string> refs = FindReferencesInProject.FindObjectReference(obj); referenceCache[depPath] = refs; } foreach (string depPath in assetPaths) { bool needDel = true; CheckOnlyOnePath(depPath, assetPath, referenceCache, ref needDel); if (needDel) { deleteList.Add(depPath); } } foreach (string deletePath in deleteList) { Debug.Log("delete:" + deletePath); AssetDatabase.DeleteAsset(deletePath); } }
public static bool FindReferenceValidate() { return(FindReferencesInProject.FindValidate()); }
public static void FindReference() { FindReferencesInProject.Find(); }