public override bool NeedUpdate(object entity, Item accountItem, MediaServiceSearchResult searchResult) { Asset asset = (Asset)entity; AssetSearchResult result = (AssetSearchResult)searchResult; return(asset.ETag != result.ETag); }
public static IEnumerable <AssetSearchResult> GetAllAssetsOfTypeWithProgress(Type type, string folderPath = null) { AssetSearchResult item = new AssetSearchResult(); if (folderPath != null) { // It's okay to use 'Assets/' here as it's only used by the AssetList attribute drawer. folderPath = folderPath.Trim('/'); if (folderPath.StartsWith("Assets/", StringComparison.InvariantCultureIgnoreCase) == false) { folderPath = "Assets/" + folderPath; } } if (type.InheritsFrom(typeof(Component))) { string[] goGuids = folderPath == null?AssetDatabase.FindAssets("t:Prefab") : AssetDatabase.FindAssets("t:Prefab", new string[] { folderPath }); item.NumberOfResults = goGuids.Length; for (int i = 0; i < goGuids.Length; i++) { string goPath = AssetDatabase.GUIDToAssetPath(goGuids[i]); GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(goPath); go.GetComponents(type, componentListBuffer); // Consider using GetComponentsInChildren if performance is not a problem. item.CurrentIndex = i; for (int j = 0; j < componentListBuffer.Count; j++) { item.Asset = componentListBuffer[j]; yield return(item); } } } else { string[] guids = folderPath == null?AssetDatabase.FindAssets("t:" + type.Name) : AssetDatabase.FindAssets("t:" + type.Name, new string[] { folderPath }); item.NumberOfResults = guids.Length; for (int i = 0; i < guids.Length; i++) { item.CurrentIndex = i; item.Asset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[i]), type); yield return(item); } } }