// // AssetBrowserPanel:项目资产浏览器(Unity Project 窗口简化版)。 // // 左侧目录树 + 右侧文件列表(类型过滤 + 名字过滤)。与 AssetManager // 的集成点是"双击预热":model/HDR 进缓存去重(重复双击零成本), // .scene 提示走 File 菜单(加载含环境恢复/选中清理等流程,不在面板 // 重复)。拖拽到视口/Inspector 属后续迭代。 // // 目录每帧扫描:项目级目录条目有限(几十量级),filesystem 迭代开销 // 可忽略;资产规模上来后再加缓存脏标。 // #ifndef HELLOVULKAN_ASSETBROWSERPANEL_H #define HELLOVULKAN_ASSETBROWSERPANEL_H #include "EditorContext.h" #include #include // Prefab 资产拖拽 payload(Content Browser 拖 .prefab → Outliner 落点 // 实例化;字符串 = 资产相对路径)。对齐 kMaterialDragPayload 模式: // 常量住源面板头 inline constexpr const char* kPrefabDragPayload = "PREFAB_PATH"; // 模型资产拖拽 payload(Content Browser 拖 .glb/.fbx/... → Outliner // 落点创建带 MeshRenderer 的实体;字符串 = 资产相对路径) inline constexpr const char* kModelDragPayload = "MODEL_PATH"; class AssetBrowserPanel { public: void Draw(const EditorContext& ctx); private: // 视图模式:列表(行,含内联小缩略图)/ 网格(缩略图瓦片) enum class ViewMode { List, Grid }; // 目录树节点(递归);右侧内容区画 dir 下的目录+文件 void DrawDirTree(const EditorContext& ctx, const std::filesystem::path& dir); void DrawContent(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] = ""; // 视图模式 + 网格瓦片尺寸(像素) ViewMode m_ViewMode = ViewMode::List; float m_TileSize = 96.0f; // 当前选中条目(资产相对路径;空 = 无选中) std::string m_SelectedPath; }; #endif //HELLOVULKAN_ASSETBROWSERPANEL_H