/* * Returns the list of actual dynamic postprocessor methods for a particular asset. * Note: That where the asset is not yet imported, this list will be empty. */ internal static SortedSet <AssetPostprocessor.PostprocessorInfo> GetSortedDynamicPostprocessorsForAsset(string path) { var list = new SortedSet <AssetPostprocessor.PostprocessorInfo>(new CompareAssetImportPriority()); var guid = AssetDatabase.GUIDFromAssetPath(path); if (guid.Empty()) { return(list); } //Artifact Infos may contains multiple artifacts, associated with different version of the object (E.g. Main, Preview etc.) var artifactInfos = AssetDatabase.GetArtifactInfos(guid); var allMethodsNames = new List <string>(); foreach (var info in artifactInfos) { if (!info.isCurrentArtifact) { continue; } foreach (var kvp in info.dependencies) { if (kvp.Value.type == ArtifactInfoDependencyType.Dynamic) { //Try to retrieve Postprocessor Methods associated with the supplied Dependency keys string dependencyName = kvp.Key.Replace(ArtifactDifferenceReporter.kEnvironment_CustomDependency + "/", ""); if (s_PostprocessorMethodsByDependencyKey.TryGetValue(dependencyName, out var methodNames)) { allMethodsNames.AddRange(methodNames); } } } } if (allMethodsNames.Count == 0) { return(list); } /* * The asset has dynamic dependencies to an Asset Postprocessor, so let's find any Postprocessors which * implements those methods. */ var distinctMethodNames = allMethodsNames.Distinct(); foreach (Type assetPostprocessorClass in GetCachedAssetPostprocessorClasses()) { if (ImplementsAnyOfTheses(assetPostprocessorClass, distinctMethodNames, out var methods)) { if (assetPostprocessorClass.GetConstructors().Any(t => t.GetParameters().Count() == 0)) { list.Add(new AssetPostprocessor.PostprocessorInfo(assetPostprocessorClass, methods.ToArray())); } else { LogPostProcessorMissingDefaultConstructor(assetPostprocessorClass); } } } return(list); }