public static List <Object> GetAll(Type t, string targetName) { List <string> paths = AssetDatabase.FindAssets("t:" + t.Name) .Select(AssetDatabase.GUIDToAssetPath) .ToList(); NameProcessor.CutLowQualityPaths(paths, targetName); return(paths .Select(path => AssetDatabase.LoadAssetAtPath(path, t)) .ToList()); }
public static List <Component> GetAll(Type t, string targetName) { ValidateCache(); List <string> paths = PrefabCache.Instance.GetPrefabs(t); if (paths == null) { return(null); } NameProcessor.CutLowQualityPaths(paths, targetName); List <GameObject> all = paths .Select(AssetDatabase.LoadAssetAtPath <GameObject>) .Where(asset => asset != null) .ToList(); var prefabs = new List <Component>(); foreach (GameObject o in all) { PrefabAssetType type = PrefabUtility.GetPrefabAssetType(o); if (type == PrefabAssetType.MissingAsset || type == PrefabAssetType.NotAPrefab) { continue; } Component c = o.GetComponent(t); if (c != null) { prefabs.Add(c); } } return(prefabs); }