feat(editor): multi-script entities + asset browser panel

ScriptComponent now holds a list of {name, active} items (Unity
semantics: one entity, many scripts, each with its own enable bit;
component-level active stays as the master switch). ScriptRuntime
reconciles instances by name per entity -- rename/remove destroys
only the affected instances, untouched ones keep ticking. Scenes
persist Script.Items; old single-script key still loads.

AssetBrowserPanel (lightweight Unity Project window): fixed roots
(assets/scenes) as tabs, recursive directory tree, file list with
type filter (models/textures/scenes) and name substring filter,
double-click preloads models/HDRs into the asset caches (path-
deduped). Scene files point to the File menu for now; drag & drop
is a later iteration. Docked with Stats by default in fresh layouts.
This commit is contained in:
2026-10-04 00:43:06 +08:00
parent 74a2044441
commit ab7a43a686
9 changed files with 459 additions and 63 deletions
+40
View File
@@ -0,0 +1,40 @@
//
// 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;
// 类型过滤(0 = All;其余见 kTypeNames)
int m_TypeFilter = 0;
// 名字子串过滤(空 = 不过滤)
char m_NameFilter[64] = "";
};
#endif //HELLOVULKAN_ASSETBROWSERPANEL_H