The file list was hardwired to the root directory, so it was always empty (all assets live in subdirectories). Directories are now selectable from both the tree (click row) and the list (click [D] row), with a breadcrumb + Root button. Prefix check done manually (path::starts_with is missing in this libstdc++).
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
//
|
||
// AssetBrowserPanel:项目资产浏览器(Unity Project 窗口简化版)。
|
||
//
|
||
// 左侧目录树 + 右侧文件列表(类型过滤 + 名字过滤)。与 AssetManager
|
||
// 的集成点是"双击预热":model/HDR 进缓存去重(重复双击零成本),
|
||
// .scene 提示走 File 菜单(加载含环境恢复/选中清理等流程,不在面板
|
||
// 重复)。拖拽到视口/Inspector 属后续迭代。
|
||
//
|
||
// 目录每帧扫描:项目级目录条目有限(几十量级),filesystem 迭代开销
|
||
// 可忽略;资产规模上来后再加缓存脏标。
|
||
//
|
||
|
||
#ifndef HELLOVULKAN_ASSETBROWSERPANEL_H
|
||
#define HELLOVULKAN_ASSETBROWSERPANEL_H
|
||
|
||
#include "EditorContext.h"
|
||
|
||
#include <filesystem>
|
||
#include <string>
|
||
|
||
class AssetBrowserPanel {
|
||
public:
|
||
void Draw(const EditorContext& ctx);
|
||
|
||
private:
|
||
// 目录树节点(递归);右侧列表画 dir 下的文件
|
||
void DrawDirTree(const EditorContext& ctx,
|
||
const std::filesystem::path& dir);
|
||
void DrawFileList(const EditorContext& ctx,
|
||
const std::filesystem::path& dir);
|
||
|
||
// 固定根(下标即身份):项目资产 / 场景文件
|
||
int m_Root = 0;
|
||
// 当前浏览目录(点目录树切换;列表显示这里的文件)
|
||
std::filesystem::path m_CurrentDir;
|
||
// 类型过滤(0 = All;其余见 kTypeNames)
|
||
int m_TypeFilter = 0;
|
||
// 名字子串过滤(空 = 不过滤)
|
||
char m_NameFilter[64] = "";
|
||
};
|
||
|
||
#endif //HELLOVULKAN_ASSETBROWSERPANEL_H
|