/// <summary> /// アセットフィールド /// </summary> private void AssetField(Rect position, LinkAnalyzer.AssetUniqueID uniqueID) { #if SEARCH_TOOLS_DEBUG if (displayGUID) { var label = uniqueID.fileID.ToString("D9") + ":" + uniqueID.guid; EditorGUI.LabelField(position, label); } else //[fallthrough] #endif { var obj = LinkAnalyzer.ConvertUniqueIDToObject(uniqueID); CustomGUI.ObjectLabelField(position, obj); } var include = linkAnalyzer.IsInclude(uniqueID); position.xMin = position.xMax - position.height; GUI.DrawTexture(position, includeIcons[(int)include]); var assetBundle = (linkAnalyzer.GetIncludeStateFlags(uniqueID) & LinkAnalyzer.IncludeStateFlags.AssetBundle) != 0; if (assetBundle) { position.x -= position.width; GUI.DrawTexture(position, assetBundleIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } }
/// <summary> /// リンクビュー /// </summary> private void LinkView() { if (0 < Selection.objects.Length) { var sortedObjects = Selection.objects.Select(x => new{ obj = x, sortValue = GetSortStringInLinkView(x) }).ToList(); sortedObjects.Sort((x, y) => { return(string.Compare(x.sortValue, y.sortValue)); }); using (var scrollView = new EditorGUILayout.ScrollViewScope(linkViewStates[(int)analyzeMode].scrollPosition)) { foreach (var sortedObject in sortedObjects) { linkViewStates[(int)analyzeMode].scrollPosition = scrollView.scrollPosition; var uniqueID = LinkAnalyzer.ConvertObjectToUniqueID(sortedObject.obj); LinkView(uniqueID, string.Empty); } } } }
/// <summary> /// リンクビュー /// </summary> private void LinkView(LinkAnalyzer.AssetUniqueID uniqueID, string parentFoldoutUniqueID) { var isSpritePackingTag = LinkAnalyzer.IsSpritePackingTag(uniqueID); var isAssetBundle = LinkAnalyzer.IsAssetBundle(uniqueID); List <LinkAnalyzer.AssetUniqueID> nestLinks; if (isSpritePackingTag || isAssetBundle) { nestLinks = linkAnalyzer.GetLinks(uniqueID); } else { switch (analyzeMode) { case AnalyzeMode.InboundLinks: nestLinks = linkAnalyzer.GetInboundLinks(uniqueID); break; case AnalyzeMode.Links: default: nestLinks = linkAnalyzer.GetLinks(uniqueID); break; } } if ((nestLinks != null) && (nestLinks.Count == 0)) { nestLinks = null; } var childSpritePackingTag = linkAnalyzer.GetSpritePackingTag(uniqueID); if (string.IsNullOrEmpty(childSpritePackingTag)) { childSpritePackingTag = null; } var hasChild = (nestLinks != null) || (childSpritePackingTag != null); LinkAnalyzer.IncludeStateFlags includeStateFlags = 0; if (analyzeMode == AnalyzeMode.InboundLinks) { includeStateFlags = linkAnalyzer.GetIncludeStateFlags(uniqueID); if ((includeStateFlags != 0) && ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.NonInclude) == 0)) { hasChild = true; } } var currentFoldoutUniqueID = parentFoldoutUniqueID + "/" + uniqueID; if (!linkViewStates[(int)analyzeMode].Foldouts.ContainsKey(currentFoldoutUniqueID)) { linkViewStates[(int)analyzeMode].Foldouts.Add(currentFoldoutUniqueID, false); } var foldout = linkViewStates[(int)analyzeMode].Foldouts[currentFoldoutUniqueID]; var position = GUILayoutUtility.GetRect(EditorGUIUtility.fieldWidth, EditorGUIUtility.singleLineHeight); if (hasChild) { EditorGUI.BeginChangeCheck(); { var indentLevel = EditorGUI.indentLevel; var foldoutPosition = EditorGUI.IndentedRect(position); foldoutPosition.width = foldoutPosition.height; EditorGUI.indentLevel = 0; foldout = EditorGUI.Foldout(foldoutPosition, foldout, GUIContent.none); EditorGUI.indentLevel = indentLevel; } if (EditorGUI.EndChangeCheck()) { linkViewStates[(int)analyzeMode].Foldouts[currentFoldoutUniqueID] = foldout; } } position.xMin += foldoutWidth; if (isSpritePackingTag) { //SpritePackingTag var currentSpritePackingTag = LinkAnalyzer.ConvertUniqueIDToSpritePackingTag(uniqueID); var label = currentSpritePackingTag + " (SpritePackingTag)"; var icon = spritePackingTagIcon; var include = linkAnalyzer.IsIncludeFromSpritePackingTag(currentSpritePackingTag); var badgeIcons = new[] { includeIcons[(int)include] }; TreeItemField(position, label, icon, badgeIcons); } else if (isAssetBundle) { //AssetBundle var currentAssetBundle = LinkAnalyzer.ConvertUniqueIDToAssetBundle(uniqueID); var label = currentAssetBundle + " (AssetBundle)"; var icon = assetBundleIcons[(int)LinkAnalyzer.IsIncludeReturn.True]; var badgeIcons = new[] { null, icon }; TreeItemField(position, label, icon, badgeIcons); } else { //Object AssetField(position, uniqueID); } if (foldout) { ++EditorGUI.indentLevel; if (nestLinks != null) { foreach (var nestUniqueID in nestLinks) { LinkView(nestUniqueID, currentFoldoutUniqueID); } } if (childSpritePackingTag != null) { var nestUniqueID = LinkAnalyzer.ConvertSpritePackingTagToUniqueID(childSpritePackingTag); LinkView(nestUniqueID, currentFoldoutUniqueID); } if ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.Scripts) != 0) { IncludeLabelView("Scripts", includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True], includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } if ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.Resources) != 0) { IncludeLabelView("Resources", includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True], includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } if ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.StreamingAssets) != 0) { IncludeLabelView("StreamingAssets", includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True], includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } if ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.ScenesInBuild) != 0) { IncludeLabelView("Build Settings", includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True], includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } if ((includeStateFlags & LinkAnalyzer.IncludeStateFlags.AlwaysIncludedShaders) != 0) { IncludeLabelView("Project Setting/Graphics Settings", includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True], includeIcons[(int)LinkAnalyzer.IsIncludeReturn.True]); } --EditorGUI.indentLevel; } }