Skip to content

Commit

Permalink
[update][editor]:增加文件后描述信息的绘制开关,重构资源包构建窗口的修改自动保存逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
CatImmortal committed May 18, 2023
1 parent 01c8385 commit 626aced
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 50 deletions.
9 changes: 9 additions & 0 deletions Assets/CatAsset/Editor/Config/BundleBuildConfigSO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public static BundleBuildConfigSO Instance
/// 是否记录精准的贴图长度
/// </summary>
public bool IsExactTextureSize;

/// <summary>
/// 是否绘制Project窗口下,文件/文件夹描述信息的工具类
/// </summary>
public bool IsDrawDesc;

/// <summary>
/// 刷新资源包构建信息
Expand Down Expand Up @@ -481,6 +486,10 @@ private void RefreshDirectoryDict()
DirectoryDict.Clear();
foreach (BundleBuildDirectory item in Directories)
{
if (string.IsNullOrEmpty(item.DirectoryName))
{
continue;
}
DirectoryDict[item.DirectoryName] = item;
}
}
Expand Down
60 changes: 28 additions & 32 deletions Assets/CatAsset/Editor/Misc/DrawDescTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,42 @@ private static void InitializeOnLoadMethod()

private static void OnGUI(string guid, Rect selectionRect)
{
if (BundleBuildConfigSO.Instance == null || BundleBuildConfigSO.Instance.Directories == null)
{
return;
}

if (!BundleBuildConfigSO.Instance.IsDrawDesc)
{
return;
}

try
if (BundleBuildConfigSO.Instance.Directories.Count > 0 && BundleBuildConfigSO.Instance.DirectoryDict.Count == 0)
{
if (BundleBuildConfigSO.Instance == null || BundleBuildConfigSO.Instance.Directories == null)
{
return;
}
BundleBuildConfigSO.Instance.RefreshDict();
}

if (BundleBuildConfigSO.Instance.Directories.Count > 0 && BundleBuildConfigSO.Instance.DirectoryDict.Count == 0)
string path = AssetDatabase.GUIDToAssetPath(guid);
if (AssetDatabase.IsValidFolder(path))
{
//是目录
if (BundleBuildConfigSO.Instance.DirectoryDict.TryGetValue(path,out BundleBuildDirectory bbd))
{
BundleBuildConfigSO.Instance.RefreshDict();
//绘制资源组在文件夹后面
//string desc = $"{bbd.Group}|{bbd.BuildRuleName}";
string desc = bbd.Group;
DrawDesc(desc,selectionRect,dirColor);
}


string path = AssetDatabase.GUIDToAssetPath(guid);
if (AssetDatabase.IsValidFolder(path))
{
//是目录
if (BundleBuildConfigSO.Instance.DirectoryDict.TryGetValue(path,out BundleBuildDirectory bbd))
{
//绘制资源组在文件夹后面
//string desc = $"{bbd.Group}|{bbd.BuildRuleName}";
string desc = bbd.Group;
DrawDesc(desc,selectionRect,dirColor);
}

}
else
{
if (BundleBuildConfigSO.Instance.AssetToBundleDict.TryGetValue(path,out BundleBuildInfo bbi))
{
//绘制资源包标识名在文件后面
string desc = bbi.BundleIdentifyName;
DrawDesc(desc,selectionRect,assetColor);
}
}
}
catch (Exception e)
else
{
Debug.LogError(e);
if (BundleBuildConfigSO.Instance.AssetToBundleDict.TryGetValue(path,out BundleBuildInfo bbi))
{
//绘制资源包标识名在文件后面
string desc = bbi.BundleIdentifyName;
DrawDesc(desc,selectionRect,assetColor);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,25 @@ private void OnEnable()

private void OnGUI()
{
selectedTab = GUILayout.Toolbar(selectedTab, tabs);

curSubWindow = subWindows[selectedTab];
if (curSubWindow is BaseTreeViewSubWindow treeViewSubWindow)
using (var check = new EditorGUI.ChangeCheckScope())
{
DrawTreeViewToolBar(treeViewSubWindow);
selectedTab = GUILayout.Toolbar(selectedTab, tabs);

curSubWindow = subWindows[selectedTab];
if (curSubWindow is BaseTreeViewSubWindow treeViewSubWindow)
{
DrawTreeViewToolBar(treeViewSubWindow);

}
curSubWindow.DrawSubWindow(position);

//保存修改
if (check.changed)
{
EditorUtility.SetDirty(BundleBuildConfigSO.Instance);
AssetDatabase.SaveAssets();
}
}
curSubWindow.DrawSubWindow(position);
}


Expand Down Expand Up @@ -107,9 +117,6 @@ private void DrawTreeViewToolBar(BaseTreeViewSubWindow treeViewSubWindow)
return;
}
}



((TreeView)treeViewSubWindow.TreeView).Reload();
}

Expand Down Expand Up @@ -146,12 +153,17 @@ private void DrawTreeViewToolBar(BaseTreeViewSubWindow treeViewSubWindow)
{
LoopDependencyAnalyzer.AnalyzeBundle(BundleBuildConfigSO.Instance.Bundles);
}

x += width;
x += 10;
width = 150;
BundleBuildConfigSO.Instance.IsExactTextureSize = GUI.Toggle(new Rect(x,y,width,height),BundleBuildConfigSO.Instance.IsExactTextureSize,"准确预估贴图大小");

x += width;
x += 10;
width = 150;
BundleBuildConfigSO.Instance.IsDrawDesc = GUI.Toggle(new Rect(x,y,width,height),BundleBuildConfigSO.Instance.IsDrawDesc,"绘制文件后描述信息");

x += width;
x += 10;
width = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public override void InitSubWindow()

public override void DrawSubWindow(Rect position)
{
EditorGUI.BeginChangeCheck();

DrawVersion();

DrawTargetPlatforms();
Expand All @@ -48,12 +46,6 @@ public override void DrawSubWindow(Rect position)
DrawCopyGroup();

DrawButtons();

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(BundleBuildConfigSO.Instance);
AssetDatabase.SaveAssets();
}
}

/// <summary>
Expand Down

0 comments on commit 626aced

Please sign in to comment.