52 lines
1.9 KiB
C++
52 lines
1.9 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>
|
||
|
||
// 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:
|
||
// 目录树节点(递归);右侧列表画 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
|