public static Component GetOne(Type t, string targetName) { ValidateCache(); List <string> paths = PrefabCache.Instance.GetPrefabs(t); if (paths == null) { return(null); } (string bestPath, _) = NameProcessor.GetMatching(paths, targetName); return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath).GetComponent(t)); }
public static Object GetOne(Type t, string targetName) { List <string> paths = AssetDatabase.FindAssets("t:" + t.Name) .Select(AssetDatabase.GUIDToAssetPath) .ToList(); if (paths.Count == 0) { return(null); } (string bestPath, _) = NameProcessor.GetMatching(paths, targetName); return(AssetDatabase.LoadAssetAtPath(bestPath, t)); }
public static GameObject GetOne(string targetName) { ValidateCache(); (Type bestType, int typeScore) = NameProcessor.GetMatching(PrefabCache.Instance.AllTypes, targetName); (string bestPath, int pathScore) = NameProcessor.GetMatching(PrefabCache.Instance.AllPaths, targetName); if (typeScore > pathScore) { List <string> paths = PrefabCache.Instance.GetPrefabs(bestType); if (paths != null) { (bestPath, _) = NameProcessor.GetMatching(paths, targetName); } } return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath)); }