public static List <string> GetReferencesByType <T>(string assetPath, APAssetType type, string progressInfo, float startProgress, float endProcess, ref bool cancel) where T : APAsset { List <string> references = new List <string>(); var lookForSet = APCache.GetAssetsListByTypeFromCache <T>(type); string title = "Find references"; float progress = 0; for (int i = 0; i < lookForSet.Count; i++) { var dependences = AssetDatabase.GetDependencies(new string[] { lookForSet[i].Path }); if (dependences.Any(denpend => denpend.Equals(assetPath, StringComparison.CurrentCultureIgnoreCase))) { references.Add(lookForSet[i].Path); } progress = startProgress + (endProcess - startProgress) * (i + 1) * 1f / lookForSet.Count; if (EditorUtility.DisplayCancelableProgressBar(title, progressInfo, progress)) { cancel = true; break; } ; } return(references); }
private static void HandleDeletedAssets(string[] deletedAssets) { var animationClips = APCache.GetAssetsListByTypeFromCache <APAnimation>(APAssetType.AnimationClip); foreach (var assetPath in deletedAssets) { Utility.DebugLog(string.Format("Deleted: {0}", assetPath)); if (Utility.IsModelPath(assetPath)) { foreach (var clip in animationClips) { if (clip.Path.Contains(assetPath)) { APCache.Remove(APAssetType.AnimationClip, clip.Id); SyncManager.DeleteAssets.Enqueue(clip); SyncManager.DeleteAssets.Enqueue(APResources.GetBlackListAPAsset(assetPath)); } } } var id = AssetDatabase.AssetPathToGUID(assetPath); var asset = APCache.GetValue(AssetDatabase.AssetPathToGUID(assetPath)); if (asset != null) { APCache.Remove(id); APCache.RemoveFromBlacklist(assetPath); SyncManager.DeleteAssets.Enqueue(asset); SyncManager.DeleteAssets.Enqueue(APResources.GetBlackListAPAsset(assetPath)); } } }
private static string GenerateCSV <T>(string header, APAssetType type, Func <T, string> rowDataGenerator) where T : APAsset { var dataSet = APCache.GetAssetsListByTypeFromCache <T>(type); StringBuilder sb = new StringBuilder(); sb.AppendLine(header); foreach (var item in dataSet) { sb.AppendLine(rowDataGenerator(item)); } return(sb.ToString()); }
private static List <string> GetReferences <T>(string assetPath, APAssetType type) where T : APAsset { List <string> references = new List <string>(); var lookForSet = APCache.GetAssetsListByTypeFromCache <T>(type); foreach (var asset in lookForSet) { var dependences = AssetDatabase.GetDependencies(new string[] { asset.Path }); if (dependences.Any(denpend => denpend.Equals(assetPath, StringComparison.CurrentCultureIgnoreCase))) { references.Add(asset.Path); } } return(references); }
private static void UpdateModelInCache(string modelAssetPath) { var guid = AssetDatabase.AssetPathToGUID(modelAssetPath); webCommunicationService.UpdateObjectsIntoCache(APAssetType.Model, guid, SyncManager.ModifiedAssets); var animationsInCache = APCache.GetAssetsListByTypeFromCache <APAnimation>(APAssetType.AnimationClip); HashSet <string> animationsAssetIdInCache = new HashSet <string>(); foreach (var animation in animationsInCache) { if (animation.Id.ToLower().Contains(guid.ToLower())) { animationsAssetIdInCache.Add(animation.Id); } } var clipIds = APResources.GetAnimationClipAssetIdInModel(modelAssetPath); foreach (var id in clipIds) { if (animationsAssetIdInCache.Contains(id)) { webCommunicationService.UpdateObjectsIntoCache(APAssetType.AnimationClip, id, SyncManager.ModifiedAssets); } else { var clip = APResources.GetAPAssetByPath(APAssetType.AnimationClip, id); APCache.SetValue(APAssetType.AnimationClip, id, clip); SyncManager.AddedAssets.Enqueue(clip); } } foreach (var id in animationsAssetIdInCache) { if (!clipIds.Contains(id)) { var clip = APCache.GetValue(APAssetType.AnimationClip, id); APCache.Remove(id); SyncManager.DeleteAssets.Enqueue(clip); } } }