初始化仓库
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public enum AssetsOrder : byte
|
||||
{
|
||||
AssetNameAsc,
|
||||
AssetNameDesc,
|
||||
DependencyResourceCountAsc,
|
||||
DependencyResourceCountDesc,
|
||||
DependencyAssetCountAsc,
|
||||
DependencyAssetCountDesc,
|
||||
ScatteredDependencyAssetCountAsc,
|
||||
ScatteredDependencyAssetCountDesc,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53e74863b20de0742bad85898d617db6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed class DependencyData
|
||||
{
|
||||
private List<Resource> m_DependencyResources;
|
||||
private List<Asset> m_DependencyAssets;
|
||||
private List<string> m_ScatteredDependencyAssetNames;
|
||||
|
||||
public DependencyData()
|
||||
{
|
||||
m_DependencyResources = new List<Resource>();
|
||||
m_DependencyAssets = new List<Asset>();
|
||||
m_ScatteredDependencyAssetNames = new List<string>();
|
||||
}
|
||||
|
||||
public int DependencyResourceCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DependencyResources.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int DependencyAssetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DependencyAssets.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int ScatteredDependencyAssetCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ScatteredDependencyAssetNames.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddDependencyAsset(Asset asset)
|
||||
{
|
||||
if (!m_DependencyResources.Contains(asset.Resource))
|
||||
{
|
||||
m_DependencyResources.Add(asset.Resource);
|
||||
}
|
||||
|
||||
m_DependencyAssets.Add(asset);
|
||||
}
|
||||
|
||||
public void AddScatteredDependencyAsset(string dependencyAssetName)
|
||||
{
|
||||
m_ScatteredDependencyAssetNames.Add(dependencyAssetName);
|
||||
}
|
||||
|
||||
public Resource[] GetDependencyResources()
|
||||
{
|
||||
return m_DependencyResources.ToArray();
|
||||
}
|
||||
|
||||
public Asset[] GetDependencyAssets()
|
||||
{
|
||||
return m_DependencyAssets.ToArray();
|
||||
}
|
||||
|
||||
public string[] GetScatteredDependencyAssetNames()
|
||||
{
|
||||
return m_ScatteredDependencyAssetNames.ToArray();
|
||||
}
|
||||
|
||||
public void RefreshData()
|
||||
{
|
||||
m_DependencyResources.Sort(DependencyResourcesComparer);
|
||||
m_DependencyAssets.Sort(DependencyAssetsComparer);
|
||||
m_ScatteredDependencyAssetNames.Sort();
|
||||
}
|
||||
|
||||
private int DependencyResourcesComparer(Resource a, Resource b)
|
||||
{
|
||||
return a.FullName.CompareTo(b.FullName);
|
||||
}
|
||||
|
||||
private int DependencyAssetsComparer(Asset a, Asset b)
|
||||
{
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 325edc30663628f4a917226eeee0b733
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,533 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源分析器。
|
||||
/// </summary>
|
||||
internal sealed class ResourceAnalyzer : EditorWindow
|
||||
{
|
||||
private ResourceAnalyzerController m_Controller = null;
|
||||
private bool m_Analyzed = false;
|
||||
private int m_ToolbarIndex = 0;
|
||||
|
||||
private int m_AssetCount = 0;
|
||||
private string[] m_CachedAssetNames = null;
|
||||
private int m_SelectedAssetIndex = -1;
|
||||
private string m_SelectedAssetName = null;
|
||||
private DependencyData m_SelectedDependencyData = null;
|
||||
private AssetsOrder m_AssetsOrder = AssetsOrder.AssetNameAsc;
|
||||
private string m_AssetsFilter = null;
|
||||
private Vector2 m_AssetsScroll = Vector2.zero;
|
||||
private Vector2 m_DependencyResourcesScroll = Vector2.zero;
|
||||
private Vector2 m_DependencyAssetsScroll = Vector2.zero;
|
||||
private Vector2 m_ScatteredDependencyAssetsScroll = Vector2.zero;
|
||||
|
||||
private int m_ScatteredAssetCount = 0;
|
||||
private string[] m_CachedScatteredAssetNames = null;
|
||||
private int m_SelectedScatteredAssetIndex = -1;
|
||||
private string m_SelectedScatteredAssetName = null;
|
||||
private Asset[] m_SelectedHostAssets = null;
|
||||
private ScatteredAssetsOrder m_ScatteredAssetsOrder = ScatteredAssetsOrder.AssetNameAsc;
|
||||
private string m_ScatteredAssetsFilter = null;
|
||||
private Vector2 m_ScatteredAssetsScroll = Vector2.zero;
|
||||
private Vector2 m_HostAssetsScroll = Vector2.zero;
|
||||
|
||||
private int m_CircularDependencyCount = 0;
|
||||
private string[][] m_CachedCircularDependencyDatas = null;
|
||||
private Vector2 m_CircularDependencyScroll = Vector2.zero;
|
||||
|
||||
[MenuItem("Game Framework/Resource Tools/Resource Analyzer", false, 42)]
|
||||
private static void Open()
|
||||
{
|
||||
ResourceAnalyzer window = GetWindow<ResourceAnalyzer>("Resource Analyzer", true);
|
||||
window.minSize = new Vector2(800f, 600f);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Controller = new ResourceAnalyzerController();
|
||||
m_Controller.OnLoadingResource += OnLoadingResource;
|
||||
m_Controller.OnLoadingAsset += OnLoadingAsset;
|
||||
m_Controller.OnLoadCompleted += OnLoadCompleted;
|
||||
m_Controller.OnAnalyzingAsset += OnAnalyzingAsset;
|
||||
m_Controller.OnAnalyzeCompleted += OnAnalyzeCompleted;
|
||||
|
||||
m_Analyzed = false;
|
||||
m_ToolbarIndex = 0;
|
||||
|
||||
m_AssetCount = 0;
|
||||
m_CachedAssetNames = null;
|
||||
m_SelectedAssetIndex = -1;
|
||||
m_SelectedAssetName = null;
|
||||
m_SelectedDependencyData = new DependencyData();
|
||||
m_AssetsOrder = AssetsOrder.ScatteredDependencyAssetCountDesc;
|
||||
m_AssetsFilter = null;
|
||||
m_AssetsScroll = Vector2.zero;
|
||||
m_DependencyResourcesScroll = Vector2.zero;
|
||||
m_DependencyAssetsScroll = Vector2.zero;
|
||||
m_ScatteredDependencyAssetsScroll = Vector2.zero;
|
||||
|
||||
m_ScatteredAssetCount = 0;
|
||||
m_CachedScatteredAssetNames = null;
|
||||
m_SelectedScatteredAssetIndex = -1;
|
||||
m_SelectedScatteredAssetName = null;
|
||||
m_SelectedHostAssets = new Asset[] { };
|
||||
m_ScatteredAssetsOrder = ScatteredAssetsOrder.HostAssetCountDesc;
|
||||
m_ScatteredAssetsFilter = null;
|
||||
m_ScatteredAssetsScroll = Vector2.zero;
|
||||
m_HostAssetsScroll = Vector2.zero;
|
||||
|
||||
m_CircularDependencyCount = 0;
|
||||
m_CachedCircularDependencyDatas = null;
|
||||
m_CircularDependencyScroll = Vector2.zero;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width), GUILayout.Height(position.height));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
int toolbarIndex = GUILayout.Toolbar(m_ToolbarIndex, new string[] { "Summary", "Asset Dependency Viewer", "Scattered Asset Viewer", "Circular Dependency Viewer" }, GUILayout.Height(30f));
|
||||
if (toolbarIndex != m_ToolbarIndex)
|
||||
{
|
||||
m_ToolbarIndex = toolbarIndex;
|
||||
GUI.FocusControl(null);
|
||||
}
|
||||
|
||||
switch (m_ToolbarIndex)
|
||||
{
|
||||
case 0:
|
||||
DrawSummary();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
DrawAssetDependencyViewer();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
DrawScatteredAssetViewer();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
DrawCircularDependencyViewer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawAnalyzeButton()
|
||||
{
|
||||
if (!m_Analyzed)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Please analyze first.", MessageType.Info);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Analyze", GUILayout.Height(30f)))
|
||||
{
|
||||
m_Controller.Clear();
|
||||
|
||||
m_SelectedAssetIndex = -1;
|
||||
m_SelectedAssetName = null;
|
||||
m_SelectedDependencyData = new DependencyData();
|
||||
|
||||
m_SelectedScatteredAssetIndex = -1;
|
||||
m_SelectedScatteredAssetName = null;
|
||||
m_SelectedHostAssets = new Asset[] { };
|
||||
|
||||
if (m_Controller.Prepare())
|
||||
{
|
||||
m_Controller.Analyze();
|
||||
m_Analyzed = true;
|
||||
m_AssetCount = m_Controller.GetAssetNames().Length;
|
||||
m_ScatteredAssetCount = m_Controller.GetScatteredAssetNames().Length;
|
||||
m_CachedCircularDependencyDatas = m_Controller.GetCircularDependencyDatas();
|
||||
m_CircularDependencyCount = m_CachedCircularDependencyDatas.Length;
|
||||
OnAssetsOrderOrFilterChanged();
|
||||
OnScatteredAssetsOrderOrFilterChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorUtility.DisplayDialog("Resource Analyze", "Can not parse 'ResourceCollection.xml', please use 'Resource Editor' tool first.", "OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSummary()
|
||||
{
|
||||
DrawAnalyzeButton();
|
||||
}
|
||||
|
||||
private void DrawAssetDependencyViewer()
|
||||
{
|
||||
if (!m_Analyzed)
|
||||
{
|
||||
DrawAnalyzeButton();
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.4f));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
string title = null;
|
||||
if (string.IsNullOrEmpty(m_AssetsFilter))
|
||||
{
|
||||
title = Utility.Text.Format("Assets In Resources ({0})", m_AssetCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = Utility.Text.Format("Assets In Resources ({0}/{1})", m_CachedAssetNames.Length, m_AssetCount);
|
||||
}
|
||||
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 150f));
|
||||
{
|
||||
m_AssetsScroll = EditorGUILayout.BeginScrollView(m_AssetsScroll);
|
||||
{
|
||||
int selectedIndex = GUILayout.SelectionGrid(m_SelectedAssetIndex, m_CachedAssetNames, 1, "toggle");
|
||||
if (selectedIndex != m_SelectedAssetIndex)
|
||||
{
|
||||
m_SelectedAssetIndex = selectedIndex;
|
||||
m_SelectedAssetName = m_CachedAssetNames[selectedIndex];
|
||||
m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedAssetName);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.LabelField("Asset Name", m_SelectedAssetName ?? "<None>");
|
||||
EditorGUILayout.LabelField("Resource Name", m_SelectedAssetName == null ? "<None>" : m_Controller.GetAsset(m_SelectedAssetName).Resource.FullName);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
AssetsOrder assetsOrder = (AssetsOrder)EditorGUILayout.EnumPopup("Order by", m_AssetsOrder);
|
||||
if (assetsOrder != m_AssetsOrder)
|
||||
{
|
||||
m_AssetsOrder = assetsOrder;
|
||||
OnAssetsOrderOrFilterChanged();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
string assetsFilter = EditorGUILayout.TextField("Assets Filter", m_AssetsFilter);
|
||||
if (assetsFilter != m_AssetsFilter)
|
||||
{
|
||||
m_AssetsFilter = assetsFilter;
|
||||
OnAssetsOrderOrFilterChanged();
|
||||
}
|
||||
EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_AssetsFilter));
|
||||
{
|
||||
if (GUILayout.Button("x", GUILayout.Width(20f)))
|
||||
{
|
||||
m_AssetsFilter = null;
|
||||
GUI.FocusControl(null);
|
||||
OnAssetsOrderOrFilterChanged();
|
||||
}
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.6f - 14f));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField(Utility.Text.Format("Dependency Resources ({0})", m_SelectedDependencyData.DependencyResourceCount), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.2f));
|
||||
{
|
||||
m_DependencyResourcesScroll = EditorGUILayout.BeginScrollView(m_DependencyResourcesScroll);
|
||||
{
|
||||
Resource[] dependencyResources = m_SelectedDependencyData.GetDependencyResources();
|
||||
foreach (Resource dependencyResource in dependencyResources)
|
||||
{
|
||||
GUILayout.Label(dependencyResource.FullName);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.LabelField(Utility.Text.Format("Dependency Assets ({0})", m_SelectedDependencyData.DependencyAssetCount), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.3f));
|
||||
{
|
||||
m_DependencyAssetsScroll = EditorGUILayout.BeginScrollView(m_DependencyAssetsScroll);
|
||||
{
|
||||
Asset[] dependencyAssets = m_SelectedDependencyData.GetDependencyAssets();
|
||||
foreach (Asset dependencyAsset in dependencyAssets)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("GO", GUILayout.Width(30f)))
|
||||
{
|
||||
m_SelectedAssetName = dependencyAsset.Name;
|
||||
m_SelectedAssetIndex = new List<string>(m_CachedAssetNames).IndexOf(m_SelectedAssetName);
|
||||
m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedAssetName);
|
||||
}
|
||||
|
||||
GUILayout.Label(dependencyAsset.Name);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.LabelField(Utility.Text.Format("Scattered Dependency Assets ({0})", m_SelectedDependencyData.ScatteredDependencyAssetCount), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.5f - 116f));
|
||||
{
|
||||
m_ScatteredDependencyAssetsScroll = EditorGUILayout.BeginScrollView(m_ScatteredDependencyAssetsScroll);
|
||||
{
|
||||
string[] scatteredDependencyAssetNames = m_SelectedDependencyData.GetScatteredDependencyAssetNames();
|
||||
foreach (string scatteredDependencyAssetName in scatteredDependencyAssetNames)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
int count = m_Controller.GetHostAssets(scatteredDependencyAssetName).Length;
|
||||
EditorGUI.BeginDisabledGroup(count < 2);
|
||||
{
|
||||
if (GUILayout.Button("GO", GUILayout.Width(30f)))
|
||||
{
|
||||
m_SelectedScatteredAssetName = scatteredDependencyAssetName;
|
||||
m_SelectedScatteredAssetIndex = new List<string>(m_CachedScatteredAssetNames).IndexOf(m_SelectedScatteredAssetName);
|
||||
m_SelectedHostAssets = m_Controller.GetHostAssets(m_SelectedScatteredAssetName);
|
||||
m_ToolbarIndex = 2;
|
||||
GUI.FocusControl(null);
|
||||
}
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
GUILayout.Label(count > 1 ? Utility.Text.Format("{0} ({1})", scatteredDependencyAssetName, count) : scatteredDependencyAssetName);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawScatteredAssetViewer()
|
||||
{
|
||||
if (!m_Analyzed)
|
||||
{
|
||||
DrawAnalyzeButton();
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.4f));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
string title = null;
|
||||
if (string.IsNullOrEmpty(m_ScatteredAssetsFilter))
|
||||
{
|
||||
title = Utility.Text.Format("Scattered Assets ({0})", m_ScatteredAssetCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = Utility.Text.Format("Scattered Assets ({0}/{1})", m_CachedScatteredAssetNames.Length, m_ScatteredAssetCount);
|
||||
}
|
||||
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 132f));
|
||||
{
|
||||
m_ScatteredAssetsScroll = EditorGUILayout.BeginScrollView(m_ScatteredAssetsScroll);
|
||||
{
|
||||
int selectedIndex = GUILayout.SelectionGrid(m_SelectedScatteredAssetIndex, m_CachedScatteredAssetNames, 1, "toggle");
|
||||
if (selectedIndex != m_SelectedScatteredAssetIndex)
|
||||
{
|
||||
m_SelectedScatteredAssetIndex = selectedIndex;
|
||||
m_SelectedScatteredAssetName = m_CachedScatteredAssetNames[selectedIndex];
|
||||
m_SelectedHostAssets = m_Controller.GetHostAssets(m_SelectedScatteredAssetName);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
EditorGUILayout.LabelField("Scattered Asset Name", m_SelectedScatteredAssetName ?? "<None>");
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
ScatteredAssetsOrder scatteredAssetsOrder = (ScatteredAssetsOrder)EditorGUILayout.EnumPopup("Order by", m_ScatteredAssetsOrder);
|
||||
if (scatteredAssetsOrder != m_ScatteredAssetsOrder)
|
||||
{
|
||||
m_ScatteredAssetsOrder = scatteredAssetsOrder;
|
||||
OnScatteredAssetsOrderOrFilterChanged();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
string scatteredAssetsFilter = EditorGUILayout.TextField("Assets Filter", m_ScatteredAssetsFilter);
|
||||
if (scatteredAssetsFilter != m_ScatteredAssetsFilter)
|
||||
{
|
||||
m_ScatteredAssetsFilter = scatteredAssetsFilter;
|
||||
OnScatteredAssetsOrderOrFilterChanged();
|
||||
}
|
||||
EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_ScatteredAssetsFilter));
|
||||
{
|
||||
if (GUILayout.Button("x", GUILayout.Width(20f)))
|
||||
{
|
||||
m_ScatteredAssetsFilter = null;
|
||||
GUI.FocusControl(null);
|
||||
OnScatteredAssetsOrderOrFilterChanged();
|
||||
}
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.6f - 14f));
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField(Utility.Text.Format("Host Assets ({0})", m_SelectedHostAssets.Length), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 68f));
|
||||
{
|
||||
m_HostAssetsScroll = EditorGUILayout.BeginScrollView(m_HostAssetsScroll);
|
||||
{
|
||||
foreach (Asset hostAsset in m_SelectedHostAssets)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("GO", GUILayout.Width(30f)))
|
||||
{
|
||||
m_SelectedAssetName = hostAsset.Name;
|
||||
m_SelectedAssetIndex = new List<string>(m_CachedAssetNames).IndexOf(m_SelectedAssetName);
|
||||
m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedAssetName);
|
||||
m_ToolbarIndex = 1;
|
||||
GUI.FocusControl(null);
|
||||
}
|
||||
|
||||
GUILayout.Label(Utility.Text.Format("{0} [{1}]", hostAsset.Name, hostAsset.Resource.FullName));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawCircularDependencyViewer()
|
||||
{
|
||||
if (!m_Analyzed)
|
||||
{
|
||||
DrawAnalyzeButton();
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField(Utility.Text.Format("Circular Dependency ({0})", m_CircularDependencyCount), EditorStyles.boldLabel);
|
||||
m_CircularDependencyScroll = EditorGUILayout.BeginScrollView(m_CircularDependencyScroll);
|
||||
{
|
||||
int count = 0;
|
||||
foreach (string[] circularDependencyData in m_CachedCircularDependencyDatas)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("{0}) {1}", ++count, circularDependencyData[circularDependencyData.Length - 1]), EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
{
|
||||
foreach (string circularDependency in circularDependencyData)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(circularDependency);
|
||||
if (GUILayout.Button("GO", GUILayout.Width(30f)))
|
||||
{
|
||||
m_SelectedAssetName = circularDependency;
|
||||
m_SelectedAssetIndex = new List<string>(m_CachedAssetNames).IndexOf(m_SelectedAssetName);
|
||||
m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedAssetName);
|
||||
m_ToolbarIndex = 1;
|
||||
GUI.FocusControl(null);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
GUILayout.Space(5f);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void OnAssetsOrderOrFilterChanged()
|
||||
{
|
||||
m_CachedAssetNames = m_Controller.GetAssetNames(m_AssetsOrder, m_AssetsFilter);
|
||||
if (!string.IsNullOrEmpty(m_SelectedAssetName))
|
||||
{
|
||||
m_SelectedAssetIndex = new List<string>(m_CachedAssetNames).IndexOf(m_SelectedAssetName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnScatteredAssetsOrderOrFilterChanged()
|
||||
{
|
||||
m_CachedScatteredAssetNames = m_Controller.GetScatteredAssetNames(m_ScatteredAssetsOrder, m_ScatteredAssetsFilter);
|
||||
if (!string.IsNullOrEmpty(m_SelectedScatteredAssetName))
|
||||
{
|
||||
m_SelectedScatteredAssetIndex = new List<string>(m_CachedScatteredAssetNames).IndexOf(m_SelectedScatteredAssetName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoadingResource(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Loading Resources", Utility.Text.Format("Loading resources, {0}/{1} loaded.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnLoadingAsset(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Loading Assets", Utility.Text.Format("Loading assets, {0}/{1} loaded.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnLoadCompleted()
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
|
||||
private void OnAnalyzingAsset(int index, int count)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("Analyzing Assets", Utility.Text.Format("Analyzing assets, {0}/{1} analyzed.", index, count), (float)index / count);
|
||||
}
|
||||
|
||||
private void OnAnalyzeCompleted()
|
||||
{
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e7971f49bcdc654fb34a9fdaa2a6d29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceAnalyzerController
|
||||
{
|
||||
private sealed class CircularDependencyChecker
|
||||
{
|
||||
private readonly Stamp[] m_Stamps;
|
||||
|
||||
public CircularDependencyChecker(Stamp[] stamps)
|
||||
{
|
||||
m_Stamps = stamps;
|
||||
}
|
||||
|
||||
public string[][] Check()
|
||||
{
|
||||
HashSet<string> hosts = new HashSet<string>();
|
||||
foreach (Stamp stamp in m_Stamps)
|
||||
{
|
||||
hosts.Add(stamp.HostAssetName);
|
||||
}
|
||||
|
||||
List<string[]> results = new List<string[]>();
|
||||
foreach (string host in hosts)
|
||||
{
|
||||
LinkedList<string> route = new LinkedList<string>();
|
||||
HashSet<string> visited = new HashSet<string>();
|
||||
if (Check(host, route, visited))
|
||||
{
|
||||
results.Add(route.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private bool Check(string host, LinkedList<string> route, HashSet<string> visited)
|
||||
{
|
||||
visited.Add(host);
|
||||
route.AddLast(host);
|
||||
|
||||
foreach (Stamp stamp in m_Stamps)
|
||||
{
|
||||
if (host != stamp.HostAssetName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visited.Contains(stamp.DependencyAssetName))
|
||||
{
|
||||
route.AddLast(stamp.DependencyAssetName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Check(stamp.DependencyAssetName, route, visited))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
route.RemoveLast();
|
||||
visited.Remove(host);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97329d75bce6b634282bf05ff3453fba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceAnalyzerController
|
||||
{
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
private struct Stamp
|
||||
{
|
||||
private readonly string m_HostAssetName;
|
||||
private readonly string m_DependencyAssetName;
|
||||
|
||||
public Stamp(string hostAssetName, string dependencyAssetName)
|
||||
{
|
||||
m_HostAssetName = hostAssetName;
|
||||
m_DependencyAssetName = dependencyAssetName;
|
||||
}
|
||||
|
||||
public string HostAssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HostAssetName;
|
||||
}
|
||||
}
|
||||
|
||||
public string DependencyAssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DependencyAssetName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15cf99f0cd968de4e876c49401fa5294
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,324 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public sealed partial class ResourceAnalyzerController
|
||||
{
|
||||
private readonly ResourceCollection m_ResourceCollection;
|
||||
|
||||
private readonly Dictionary<string, DependencyData> m_DependencyDatas;
|
||||
private readonly Dictionary<string, List<Asset>> m_ScatteredAssets;
|
||||
private readonly List<string[]> m_CircularDependencyDatas;
|
||||
private readonly HashSet<Stamp> m_AnalyzedStamps;
|
||||
|
||||
public ResourceAnalyzerController()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ResourceAnalyzerController(ResourceCollection resourceCollection)
|
||||
{
|
||||
m_ResourceCollection = resourceCollection != null ? resourceCollection : new ResourceCollection();
|
||||
|
||||
m_ResourceCollection.OnLoadingResource += delegate (int index, int count)
|
||||
{
|
||||
if (OnLoadingResource != null)
|
||||
{
|
||||
OnLoadingResource(index, count);
|
||||
}
|
||||
};
|
||||
|
||||
m_ResourceCollection.OnLoadingAsset += delegate (int index, int count)
|
||||
{
|
||||
if (OnLoadingAsset != null)
|
||||
{
|
||||
OnLoadingAsset(index, count);
|
||||
}
|
||||
};
|
||||
|
||||
m_ResourceCollection.OnLoadCompleted += delegate ()
|
||||
{
|
||||
if (OnLoadCompleted != null)
|
||||
{
|
||||
OnLoadCompleted();
|
||||
}
|
||||
};
|
||||
|
||||
m_DependencyDatas = new Dictionary<string, DependencyData>(StringComparer.Ordinal);
|
||||
m_ScatteredAssets = new Dictionary<string, List<Asset>>(StringComparer.Ordinal);
|
||||
m_AnalyzedStamps = new HashSet<Stamp>();
|
||||
m_CircularDependencyDatas = new List<string[]>();
|
||||
}
|
||||
|
||||
public event GameFrameworkAction<int, int> OnLoadingResource = null;
|
||||
|
||||
public event GameFrameworkAction<int, int> OnLoadingAsset = null;
|
||||
|
||||
public event GameFrameworkAction OnLoadCompleted = null;
|
||||
|
||||
public event GameFrameworkAction<int, int> OnAnalyzingAsset = null;
|
||||
|
||||
public event GameFrameworkAction OnAnalyzeCompleted = null;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
m_ResourceCollection.Clear();
|
||||
m_DependencyDatas.Clear();
|
||||
m_ScatteredAssets.Clear();
|
||||
m_CircularDependencyDatas.Clear();
|
||||
m_AnalyzedStamps.Clear();
|
||||
}
|
||||
|
||||
public bool Prepare()
|
||||
{
|
||||
m_ResourceCollection.Clear();
|
||||
return m_ResourceCollection.Load();
|
||||
}
|
||||
|
||||
public void Analyze()
|
||||
{
|
||||
m_DependencyDatas.Clear();
|
||||
m_ScatteredAssets.Clear();
|
||||
m_CircularDependencyDatas.Clear();
|
||||
m_AnalyzedStamps.Clear();
|
||||
|
||||
HashSet<string> scriptAssetNames = GetFilteredAssetNames("t:Script");
|
||||
Asset[] assets = m_ResourceCollection.GetAssets();
|
||||
int count = assets.Length;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (OnAnalyzingAsset != null)
|
||||
{
|
||||
OnAnalyzingAsset(i, count);
|
||||
}
|
||||
|
||||
string assetName = assets[i].Name;
|
||||
if (string.IsNullOrEmpty(assetName))
|
||||
{
|
||||
Debug.LogWarning(Utility.Text.Format("Can not find asset by guid '{0}'.", assets[i].Guid));
|
||||
continue;
|
||||
}
|
||||
|
||||
DependencyData dependencyData = new DependencyData();
|
||||
AnalyzeAsset(assetName, assets[i], dependencyData, scriptAssetNames);
|
||||
dependencyData.RefreshData();
|
||||
m_DependencyDatas.Add(assetName, dependencyData);
|
||||
}
|
||||
|
||||
foreach (List<Asset> scatteredAsset in m_ScatteredAssets.Values)
|
||||
{
|
||||
scatteredAsset.Sort((a, b) => a.Name.CompareTo(b.Name));
|
||||
}
|
||||
|
||||
m_CircularDependencyDatas.AddRange(new CircularDependencyChecker(m_AnalyzedStamps.ToArray()).Check());
|
||||
|
||||
if (OnAnalyzeCompleted != null)
|
||||
{
|
||||
OnAnalyzeCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
private void AnalyzeAsset(string assetName, Asset hostAsset, DependencyData dependencyData, HashSet<string> scriptAssetNames)
|
||||
{
|
||||
string[] dependencyAssetNames = AssetDatabase.GetDependencies(assetName, false);
|
||||
foreach (string dependencyAssetName in dependencyAssetNames)
|
||||
{
|
||||
if (scriptAssetNames.Contains(dependencyAssetName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dependencyAssetName == assetName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dependencyAssetName.EndsWith(".unity", StringComparison.Ordinal))
|
||||
{
|
||||
// 忽略对场景的依赖
|
||||
continue;
|
||||
}
|
||||
|
||||
Stamp stamp = new Stamp(hostAsset.Name, dependencyAssetName);
|
||||
if (m_AnalyzedStamps.Contains(stamp))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_AnalyzedStamps.Add(stamp);
|
||||
|
||||
string guid = AssetDatabase.AssetPathToGUID(dependencyAssetName);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Debug.LogWarning(Utility.Text.Format("Can not find guid by asset '{0}'.", dependencyAssetName));
|
||||
continue;
|
||||
}
|
||||
|
||||
Asset asset = m_ResourceCollection.GetAsset(guid);
|
||||
if (asset != null)
|
||||
{
|
||||
dependencyData.AddDependencyAsset(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
dependencyData.AddScatteredDependencyAsset(dependencyAssetName);
|
||||
|
||||
List<Asset> scatteredAssets = null;
|
||||
if (!m_ScatteredAssets.TryGetValue(dependencyAssetName, out scatteredAssets))
|
||||
{
|
||||
scatteredAssets = new List<Asset>();
|
||||
m_ScatteredAssets.Add(dependencyAssetName, scatteredAssets);
|
||||
}
|
||||
|
||||
scatteredAssets.Add(hostAsset);
|
||||
|
||||
AnalyzeAsset(dependencyAssetName, hostAsset, dependencyData, scriptAssetNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Asset GetAsset(string assetName)
|
||||
{
|
||||
return m_ResourceCollection.GetAsset(AssetDatabase.AssetPathToGUID(assetName));
|
||||
}
|
||||
|
||||
public string[] GetAssetNames()
|
||||
{
|
||||
return GetAssetNames(AssetsOrder.AssetNameAsc, null);
|
||||
}
|
||||
|
||||
public string[] GetAssetNames(AssetsOrder order, string filter)
|
||||
{
|
||||
HashSet<string> filteredAssetNames = GetFilteredAssetNames(filter);
|
||||
IEnumerable<KeyValuePair<string, DependencyData>> filteredResult = m_DependencyDatas.Where(pair => filteredAssetNames.Contains(pair.Key));
|
||||
IEnumerable<KeyValuePair<string, DependencyData>> orderedResult = null;
|
||||
switch (order)
|
||||
{
|
||||
case AssetsOrder.AssetNameAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Key);
|
||||
break;
|
||||
|
||||
case AssetsOrder.AssetNameDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Key);
|
||||
break;
|
||||
|
||||
case AssetsOrder.DependencyResourceCountAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Value.DependencyResourceCount);
|
||||
break;
|
||||
|
||||
case AssetsOrder.DependencyResourceCountDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Value.DependencyResourceCount);
|
||||
break;
|
||||
|
||||
case AssetsOrder.DependencyAssetCountAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Value.DependencyAssetCount);
|
||||
break;
|
||||
|
||||
case AssetsOrder.DependencyAssetCountDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Value.DependencyAssetCount);
|
||||
break;
|
||||
|
||||
case AssetsOrder.ScatteredDependencyAssetCountAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Value.ScatteredDependencyAssetCount);
|
||||
break;
|
||||
|
||||
case AssetsOrder.ScatteredDependencyAssetCountDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Value.ScatteredDependencyAssetCount);
|
||||
break;
|
||||
|
||||
default:
|
||||
orderedResult = filteredResult;
|
||||
break;
|
||||
}
|
||||
|
||||
return orderedResult.Select(pair => pair.Key).ToArray();
|
||||
}
|
||||
|
||||
public DependencyData GetDependencyData(string assetName)
|
||||
{
|
||||
DependencyData dependencyData = null;
|
||||
if (m_DependencyDatas.TryGetValue(assetName, out dependencyData))
|
||||
{
|
||||
return dependencyData;
|
||||
}
|
||||
|
||||
return dependencyData;
|
||||
}
|
||||
|
||||
public string[] GetScatteredAssetNames()
|
||||
{
|
||||
return GetScatteredAssetNames(ScatteredAssetsOrder.HostAssetCountDesc, null);
|
||||
}
|
||||
|
||||
public string[] GetScatteredAssetNames(ScatteredAssetsOrder order, string filter)
|
||||
{
|
||||
HashSet<string> filterAssetNames = GetFilteredAssetNames(filter);
|
||||
IEnumerable<KeyValuePair<string, List<Asset>>> filteredResult = m_ScatteredAssets.Where(pair => filterAssetNames.Contains(pair.Key) && pair.Value.Count > 1);
|
||||
IEnumerable<KeyValuePair<string, List<Asset>>> orderedResult = null;
|
||||
switch (order)
|
||||
{
|
||||
case ScatteredAssetsOrder.AssetNameAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Key);
|
||||
break;
|
||||
|
||||
case ScatteredAssetsOrder.AssetNameDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Key);
|
||||
break;
|
||||
|
||||
case ScatteredAssetsOrder.HostAssetCountAsc:
|
||||
orderedResult = filteredResult.OrderBy(pair => pair.Value.Count);
|
||||
break;
|
||||
|
||||
case ScatteredAssetsOrder.HostAssetCountDesc:
|
||||
orderedResult = filteredResult.OrderByDescending(pair => pair.Value.Count);
|
||||
break;
|
||||
|
||||
default:
|
||||
orderedResult = filteredResult;
|
||||
break;
|
||||
}
|
||||
|
||||
return orderedResult.Select(pair => pair.Key).ToArray();
|
||||
}
|
||||
|
||||
public Asset[] GetHostAssets(string scatteredAssetName)
|
||||
{
|
||||
List<Asset> assets = null;
|
||||
if (m_ScatteredAssets.TryGetValue(scatteredAssetName, out assets))
|
||||
{
|
||||
return assets.ToArray();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string[][] GetCircularDependencyDatas()
|
||||
{
|
||||
return m_CircularDependencyDatas.ToArray();
|
||||
}
|
||||
|
||||
private HashSet<string> GetFilteredAssetNames(string filter)
|
||||
{
|
||||
string[] filterAssetGuids = AssetDatabase.FindAssets(filter);
|
||||
HashSet<string> filterAssetNames = new HashSet<string>();
|
||||
foreach (string filterAssetGuid in filterAssetGuids)
|
||||
{
|
||||
filterAssetNames.Add(AssetDatabase.GUIDToAssetPath(filterAssetGuid));
|
||||
}
|
||||
|
||||
return filterAssetNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f05a10a252bec6c44b19b0cf7c105ff3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor.ResourceTools
|
||||
{
|
||||
public enum ScatteredAssetsOrder : byte
|
||||
{
|
||||
AssetNameAsc,
|
||||
AssetNameDesc,
|
||||
HostAssetCountAsc,
|
||||
HostAssetCountDesc,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d9068195c1bd334d8dfb4211ad27f7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user