private static void ProcessProjectScopeTargets(AssetConjunctions assetConjunctions) { var asset = assetConjunctions.asset; var type = asset.Type; var path = asset.Path; if (type == CSReflectionTools.gameObjectType) { ProcessPrefab(path); } else if (type == CSReflectionTools.sceneAssetType) { ProcessSceneForProjectLevelReferences(path, assetConjunctions.conjunctions); } else if (type == CSReflectionTools.monoScriptType) { ProcessScriptAsset(path); } else if (type != null && (type.BaseType == CSReflectionTools.scriptableObjectType || type == CSReflectionTools.monoBehaviourType)) { ProcessScriptableObjectAsset(path); } }
public static ReferencesTreeElement BuildTreeBranch(AssetInfo referencedAsset, int depth, int id, List <ReferencesTreeElement> results) { // excludes assets without references if necessary and excludes assets which were ignored if (AssetIsFilteredOut(referencedAsset, depth)) { return(null); } var assetPath = referencedAsset.Path; var assetType = referencedAsset.Type; string assetTypeName; if (referencedAsset.SettingsKind == AssetSettingsKind.NotSettings) { assetTypeName = assetType != null && !string.IsNullOrEmpty(assetType.Name) ? assetType.Name : "Unknown type"; } else { assetTypeName = "Settings Asset"; } var element = new ReferencesTreeElement { id = id + results.Count, name = CSPathTools.NicifyAssetPath(referencedAsset.Path, referencedAsset.Kind), assetPath = assetPath, assetTypeName = assetTypeName, assetSize = referencedAsset.Size, assetSizeFormatted = CSEditorTools.FormatBytes(referencedAsset.Size), assetIsTexture = assetType != null && (assetType.BaseType == CSReflectionTools.textureType), assetSettingsKind = referencedAsset.SettingsKind, isReferenced = referencedAsset.referencedAtInfoList != null && referencedAsset.referencedAtInfoList.Length > 0, depth = depth }; results.Add(element); var recursionId = CheckParentsForRecursion(element, results); if (recursionId > -1) { element.name += " [RECURSION]"; element.recursionId = recursionId; return(element); } if (referencedAsset.referencedAtInfoList.Length > 0) { foreach (var referencedAtInfo in referencedAsset.referencedAtInfoList) { //if (CSFilterTools.IsValueMatchesAnyFilter(referencedAtInfo.assetInfo.Path, MaintainerSettings.References.pathIgnoresFilters)) continue; if (referencedAtInfo.assetInfo.Kind == AssetKind.FromPackage) { continue; } var newDepth = depth + 1; if (newDepth > 1) { continue; } var childElement = BuildTreeBranch(referencedAtInfo.assetInfo, newDepth, id, results); if (childElement == null) { continue; } var referencedAtType = referencedAtInfo.assetInfo.Type; if (referencedAtType == CSReflectionTools.gameObjectType || referencedAtType == CSReflectionTools.sceneAssetType || referencedAtType == CSReflectionTools.monoScriptType || referencedAtType == CSReflectionTools.monoBehaviourType || referencedAtType != null && referencedAtType.BaseType == CSReflectionTools.scriptableObjectType) { if (referencedAtInfo.entries != null) { childElement.referencingEntries = referencedAtInfo.entries; } else { var collectedData = ReferencesFinder.ConjunctionInfoList.FirstOrDefault(d => d.asset == referencedAtInfo.assetInfo); if (collectedData == null) { collectedData = new AssetConjunctions(); ReferencesFinder.ConjunctionInfoList.Add(collectedData); collectedData.asset = referencedAtInfo.assetInfo; } var tc = collectedData.conjunctions.FirstOrDefault(c => c.referencedAsset == referencedAsset); if (tc == null) { tc = new TreeConjunction { referencedAsset = referencedAsset, referencedAtInfo = referencedAtInfo }; collectedData.conjunctions.Add(tc); } tc.treeElements.Add(childElement); } } } } return(element); }
public static bool FillReferenceEntries() { var canceled = false; var count = ReferencesFinder.ConjunctionInfoList.Count; var updateStep = Math.Max(count / MaintainerSettings.UpdateProgressStep, 1); for (var i = 0; i < count; i++) { if ((i < 10 || i % updateStep == 0) && EditorUtility.DisplayCancelableProgressBar( string.Format(ReferencesFinder.ProgressCaption, 2, ReferencesFinder.PhasesCount), string.Format(ReferencesFinder.ProgressText, "Filling reference details", i + 1, count), (float)i / count)) { canceled = true; break; } assetConjunctions = ReferencesFinder.ConjunctionInfoList[i]; var type = assetConjunctions.asset.Type; if (type == CSReflectionTools.gameObjectType) { ProcessPrefab(); } else if (type == CSReflectionTools.sceneAssetType) { ProcessScene(); } else if (type == CSReflectionTools.monoScriptType) { ProcessScriptAsset(); } else if (type != null && (type.BaseType == CSReflectionTools.scriptableObjectType || type == CSReflectionTools.monoBehaviourType)) { ProcessScriptableObjectAsset(); } foreach (var conjunction in assetConjunctions.conjunctions) { var referencedAtInfo = conjunction.referencedAtInfo; if (referencedAtInfo.entries == null || referencedAtInfo.entries.Length == 0) { var newEntry = new ReferencingEntryData { location = Location.NotFound, prefixLabel = "No exact reference place found." }; if (referencedAtInfo.assetInfo.Type == CSReflectionTools.sceneAssetType) { var sceneSpecificEntry = new ReferencingEntryData { location = Location.NotFound, prefixLabel = "Please try to remove all missing prefabs/scripts (if any) and re-save scene, it may cleanup junky dependencies." }; referencedAtInfo.entries = new[] { newEntry, sceneSpecificEntry }; } else if (referencedAtInfo.assetInfo.Type == CSReflectionTools.gameObjectType) { var prefabSpecificEntry = new ReferencingEntryData { location = Location.NotFound, prefixLabel = "Please try to re-Apply prefab explicitly, this may clean up junky dependencies." }; referencedAtInfo.entries = new[] { newEntry, prefabSpecificEntry }; } else { referencedAtInfo.entries = new[] { newEntry }; } if (ReferencesFinder.debugMode) { Debug.LogWarning(Maintainer.ConstructWarning("Couldn't determine where exactly this asset is referenced: " + conjunction.referencedAsset.Path, ReferencesFinder.ModuleName)); } } foreach (var targetTreeElement in conjunction.treeElements) { targetTreeElement.referencingEntries = referencedAtInfo.entries; } } } return(canceled); }