Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: add Addressable panel with group management, labels, drag-move, and dependency analysis

esengined3335269948b
diff --git a/editor/src/Editor.ts b/editor/src/Editor.ts
index 33bea99bb..dd6d7c5b9 100644
--- a/editor/src/Editor.ts
+++ b/editor/src/Editor.ts
@@ -234,12 +234,19 @@ export class Editor {
}
toggleBottomPanel(id: string): void {
- if (this.activeBottomPanelId_ === id) {
+ const prev = this.activeBottomPanelId_;
+ if (prev === id) {
this.activeBottomPanelId_ = null;
} else {
this.activeBottomPanelId_ = id;
}
this.updateBottomPanelVisibility();
+ if (prev && prev !== id) {
+ this.panelInstances_.get(prev)?.onHide?.();
+ }
+ if (this.activeBottomPanelId_) {
+ this.panelInstances_.get(this.activeBottomPanelId_)?.onShow?.();
+ }
}
// =========================================================================
diff --git a/editor/src/asset/AssetDatabase.ts b/editor/src/asset/AssetDatabase.ts
new file mode 100644
index 000000000..ac3379bc0
--- /dev/null
+++ b/editor/src/asset/AssetDatabase.ts
@@ -0,0 +1,519 @@
+/**
+ * @file AssetDatabase.ts
+ * @brief Unified asset metadata center with UUID mapping, labels, addresses, and groups
+ */
+
+import type { SceneData } from '../types/SceneTypes';
+import type { TextureMetadata } from '../types/TextureMetadata';
+import { joinPath, getFileExtension } from '../utils/path';
+import type { NativeFS } from '../types/NativeFS';
+import { ASSET_EXTENSIONS, getAssetType } from './AssetTypes';
+import {
+ type AssetMeta,
+ type TextureImporterSettings,
+ createDefaultMeta,
+ upgradeMeta,
+ serializeMeta,
+ getDefaultImporterForType,
+} from './ImporterTypes';
+import { AssetGroupService } from './AssetGroup';
+
+// =============================================================================
+// Types
+// =============================================================================
+
+export interface AssetEntry {
+ uuid: string;
+ path: string;
+ type: string;
+ labels: Set<string>;
+ address: string | null;
+ group: string;
+ importer: Record<string, unknown>;
+ platformOverrides: Record<string, Record<string, unknown>>;
+ fileSize: number;
+ lastModified: number;
+}
+
+const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+
+export function isUUID(value: string): boolean {
+ return UUID_REGEX.test(value);
+}
+
+// =============================================================================
+// AssetDatabase
+// =============================================================================
+
+export class AssetDatabase {
+ private uuidToEntry_ = new Map<string, AssetEntry>();
+ private pathToUuid_ = new Map<string, string>();
+ private addressToUuid_ = new Map<string, string>();
+ private labelIndex_ = new Map<string, Set<string>>();
+ private groupIndex_ = new Map<string, Set<string>>();
+ private fs_: NativeFS | null = null;
+ private projectDir_ = '';
+ private groupService_: AssetGroupService | null = null;
+
+ async initialize(projectDir: string, fs: NativeFS): Promise<void> {
+ this.fs_ = fs;
+ this.projectDir_ = projectDir;
+ this.uuidToEntry_.clear();
+ this.pathToUuid_.clear();
+ this.addressToUuid_.clear();
+ this.labelIndex_.clear();
+ this.groupIndex_.clear();
+
+ this.groupService_ = new AssetGroupService(projectDir, fs);
+ await this.groupService_.load();
+
+ const assetsDir = joinPath(projectDir, 'assets');
+ if (await fs.exists(assetsDir)) {
+ await this.scanDirectory(assetsDir, 'assets');
+ }
+ }
+
+ // =========================================================================
+ // UUID ↔ Path (backward-compatible API)
+ // =========================================================================
+
+ getPath(uuid: string): string | undefined {
+ return this.uuidToEntry_.get(uuid)?.path;
+ }
+
+ getUuid(path: string): string | undefined {
+ return this.pathToUuid_.get(path);
+ }
+
+ // =========================================================================
+ // Entry Access
+ // =========================================================================
+
+ getEntry(uuid: string): AssetEntry | undefined {
+ return this.uuidToEntry_.get(uuid);
+ }
+
+ getEntryByPath(path: string): AssetEntry | undefined {
+ const uuid = this.pathToUuid_.get(path);
+ return uuid ? this.uuidToEntry_.get(uuid) : undefined;
+ }
+
+ getAllEntries(): IterableIterator<AssetEntry> {
+ return this.uuidToEntry_.values();
+ }
+
+ get entryCount(): number {
+ return this.uuidToEntry_.size;
+ }
+
+ // =========================================================================
+ // Address Lookup
+ // =========================================================================
+
+ getUuidByAddress(address: string): string | undefined {
+ return this.addressToUuid_.get(address);
+ }
+
+ getEntryByAddress(address: string): AssetEntry | undefined {
+ const uuid = this.addressToUuid_.get(address);
+ return uuid ? this.uuidToEntry_.get(uuid) : undefined;
+ }
+
+ // =========================================================================
+ // Label Queries
+ // =========================================================================
+
+ getUuidsByLabel(label: string): Set<string> {
+ return this.labelIndex_.get(label) ?? new Set();
+ }
+
+ getAllLabels(): string[] {
+ return [...this.labelIndex_.keys()];
+ }
+
+ // =========================================================================
+ // Group Queries
+ // =========================================================================
+
+ getUuidsByGroup(group: string): Set<string> {
+ return this.groupIndex_.get(group) ?? new Set();
+ }
+
+ getAllGroups(): string[] {
+ return [...this.groupIndex_.keys()];
+ }
+
+ getGroupService(): AssetGroupService | null {
+ return this.groupService_;
+ }
+
+ // =========================================================================
+ // Meta File Operations
+ // =========================================================================
+
+ async ensureMeta(relativePath: string): Promise<string> {
+ const existing = this.pathToUuid_.get(relativePath);
+ if (existing) return existing;
+
+ if (!this.fs_) {
+ throw new Error('AssetDatabase not initialized');
+ }
+
+ const fullPath = joinPath(this.projectDir_, relativePath);
+ const metaPath = `${fullPath}.meta`;
+
+ if (await this.fs_.exists(metaPath)) {
+ const content = await this.fs_.readFile(metaPath);
+ if (content) {
+ try {
+ const raw = JSON.parse(content) as Record<string, unknown>;
+ if (raw.uuid) {
+ const meta = upgradeMeta(raw);
+ if (raw.version !== '2.0') {
+ await this.fs_.writeFile(metaPath, serializeMeta(meta));
+ }
+ this.registerEntry(meta, relativePath);
+ return meta.uuid;
+ }
+ } catch {
+ // Fall through to create new meta
+ }
+ }
+ }
+
+ const uuid = crypto.randomUUID();
+ const assetType = getAssetType(relativePath);
+ const meta = createDefaultMeta(uuid, assetType);
+
+ await this.fs_.writeFile(metaPath, serializeMeta(meta));
+ this.registerEntry(meta, relativePath);
+ return uuid;
+ }
+
+ async updateMeta(uuid: string, updates: Partial<Pick<AssetEntry, 'labels' | 'address' | 'group' | 'importer' | 'platformOverrides'>>): Promise<void> {
+ const entry = this.uuidToEntry_.get(uuid);
+ if (!entry || !this.fs_) return;
+
+ if (updates.address !== undefined) {
+ if (entry.address) {
+ this.addressToUuid_.delete(entry.address);
+ }
+ entry.address = updates.address;
+ if (updates.address) {
+ this.addressToUuid_.set(updates.address, uuid);
+ }
+ }
+
+ if (updates.labels !== undefined) {
+ for (const oldLabel of entry.labels) {
+ this.labelIndex_.get(oldLabel)?.delete(uuid);
+ }
+ entry.labels = updates.labels;
+ for (const newLabel of entry.labels) {
+ if (!this.labelIndex_.has(newLabel)) {
+ this.labelIndex_.set(newLabel, new Set());
+ }
+ this.labelIndex_.get(newLabel)!.add(uuid);
+ }
+ }
+
+ if (updates.group !== undefined) {
+ const oldGroup = entry.group;
+ this.groupIndex_.get(oldGroup)?.delete(uuid);
+ entry.group = updates.group;
+ if (!this.groupIndex_.has(updates.group)) {
+ this.groupIndex_.set(updates.group, new Set());
+ }
+ this.groupIndex_.get(updates.group)!.add(uuid);
+ }
+
+ if (updates.importer !== undefined) {
+ entry.importer = updates.importer;
+ }
+
+ if (updates.platformOverrides !== undefined) {
+ entry.platformOverrides = updates.platformOverrides;
+ }
+
+ await this.writeMetaFile(entry);
+ }
+
+ // =========================================================================
+ // Scene Migration (backward-compatible)
+ // =========================================================================
+
+ async migrateScene(scene: SceneData): Promise<boolean> {
+ if (scene.version === '2.0') return false;
+ if (!this.fs_) return false;
+
+ let changed = false;
+
+ for (const entity of scene.entities) {
+ for (const comp of entity.components || []) {
+ changed = await this.migrateComponentRefs(comp) || changed;
+ }
+ }
+
+ if (scene.textureMetadata) {
+ const newMetadata: Record<string, TextureMetadata> = {};
+ for (const [key, value] of Object.entries(scene.textureMetadata)) {
+ if (isUUID(key)) {
+ newMetadata[key] = value;
+ } else {
+ const uuid = await this.ensureMeta(key);
+ newMetadata[uuid] = value;
+ changed = true;
+ }
+ }
+ scene.textureMetadata = newMetadata;
+ }
+
+ if (changed) {
+ scene.version = '2.0';
+ }
+
+ return changed;
+ }
+
+ resolveSceneAssetPaths(scene: SceneData): void {
+ for (const entity of scene.entities) {
+ for (const comp of entity.components || []) {
+ this.resolveComponentRefs(comp);
+ }
+ }
+
+ if (scene.textureMetadata) {
+ const resolved: Record<string, TextureMetadata> = {};
+ for (const [key, value] of Object.entries(scene.textureMetadata)) {
+ if (isUUID(key)) {
+ const path = this.getPath(key);
+ resolved[path ?? key] = value;
+ } else {
+ resolved[key] = value;
+ }
+ }
+ scene.textureMetadata = resolved;
+ }
+ }
+
+ // =========================================================================
+ // Registration / Unregistration
+ // =========================================================================
+
+ unregister(relativePath: string): void {
+ const uuid = this.pathToUuid_.get(relativePath);
+ if (!uuid) return;
+
+ const entry = this.uuidToEntry_.get(uuid);
+ if (entry) {
+ if (entry.address) {
+ this.addressToUuid_.delete(entry.address);
+ }
+ for (const label of entry.labels) {
+ this.labelIndex_.get(label)?.delete(uuid);
+ }
+ this.groupIndex_.get(entry.group)?.delete(uuid);
+ }
+
+ this.uuidToEntry_.delete(uuid);
+ this.pathToUuid_.delete(relativePath);
+ }
+
+ updatePath(oldRelativePath: string, newRelativePath: string): void {
+ const uuid = this.pathToUuid_.get(oldRelativePath);
+ if (!uuid) return;
+
+ const entry = this.uuidToEntry_.get(uuid);
+ if (entry) {
+ entry.path = newRelativePath;
+ }
+ this.pathToUuid_.delete(oldRelativePath);
+ this.pathToUuid_.set(newRelativePath, uuid);
+ }
+
+ // =========================================================================
+ // Importer Convenience
+ // =========================================================================
+
+ getSliceBorder(uuid: string): { left: number; right: number; top: number; bottom: number } | null {
+ const entry = this.uuidToEntry_.get(uuid);
+ if (!entry || entry.type !== 'texture') return null;
+ const importer = entry.importer as unknown as TextureImporterSettings;
+ return importer.sliceBorder ?? null;
+ }
+
+ // =========================================================================
+ // Private
+ // =========================================================================
+
+ private registerEntry(meta: AssetMeta, relativePath: string): void {
+ const group = this.groupService_
+ ? this.groupService_.resolveGroup(relativePath, undefined)
+ : 'default';
+
+ const entry: AssetEntry = {
+ uuid: meta.uuid,
+ path: relativePath,
+ type: meta.type,
+ labels: new Set(meta.labels),
+ address: meta.address,
+ group,
+ importer: meta.importer,
+ platformOverrides: meta.platformOverrides,
+ fileSize: 0,
+ lastModified: 0,
+ };
+
+ this.uuidToEntry_.set(meta.uuid, entry);
+ this.pathToUuid_.set(relativePath, meta.uuid);
+
+ if (meta.address) {
+ this.addressToUuid_.set(meta.address, meta.uuid);
+ }
+
+ for (const label of meta.labels) {
+ if (!this.labelIndex_.has(label)) {
+ this.labelIndex_.set(label, new Set());
+ }
+ this.labelIndex_.get(label)!.add(meta.uuid);
+ }
+
+ if (!this.groupIndex_.has(group)) {
+ this.groupIndex_.set(group, new Set());
+ }
+ this.groupIndex_.get(group)!.add(meta.uuid);
+ }
+
+ private async writeMetaFile(entry: AssetEntry): Promise<void> {
+ if (!this.fs_) return;
+ const meta: AssetMeta = {
+ uuid: entry.uuid,
+ version: '2.0',
+ type: entry.type,
+ labels: [...entry.labels],
+ address: entry.address,
+ importer: entry.importer,
+ platformOverrides: entry.platformOverrides,
+ };
+ const fullPath = joinPath(this.projectDir_, entry.path);
+ await this.fs_.writeFile(`${fullPath}.meta`, serializeMeta(meta));
+ }
+
+ private async scanDirectory(absolutePath: string, relativePath: string): Promise<void> {
+ if (!this.fs_) return;
+
+ const entries = await this.fs_.listDirectoryDetailed(absolutePath);
+
+ for (const entry of entries) {
+ const childAbsolute = joinPath(absolutePath, entry.name);
+ const childRelative = `${relativePath}/${entry.name}`;
+
+ if (entry.isDirectory) {
+ await this.scanDirectory(childAbsolute, childRelative);
+ } else if (entry.name.endsWith('.meta')) {
+ const content = await this.fs_.readFile(childAbsolute);
+ if (content) {
+ try {
+ const raw = JSON.parse(content) as Record<string, unknown>;
+ if (raw.uuid) {
+ const meta = upgradeMeta(raw);
+ const assetRelPath = childRelative.replace(/\.meta$/, '');
+
+ if (raw.version !== '2.0') {
+ await this.fs_.writeFile(childAbsolute, serializeMeta(meta));
+ }
+
+ this.registerEntry(meta, assetRelPath);
+ }
+ } catch {
+ // Skip invalid meta files
+ }
+ }
+ } else {
+ const ext = getFileExtension(entry.name);
+ if (ASSET_EXTENSIONS.has(ext)) {
+ const metaAbsolute = `${childAbsolute}.meta`;
+ if (!await this.fs_.exists(metaAbsolute)) {
+ await this.ensureMeta(childRelative);
+ }
+ }
+ }
+ }
+ }
+
+ // =========================================================================
+ // Component Ref Helpers (used by migrateScene / resolveSceneAssetPaths)
+ // =========================================================================
+
+ private async migrateComponentRefs(comp: { type: string; data: Record<string, unknown> }): Promise<boolean> {
+ let changed = false;
+ const refs = getComponentRefFields(comp.type);
+ if (!refs || !comp.data) return false;
+
+ for (const field of refs) {
+ const value = comp.data[field];
+ if (typeof value === 'string' && !isUUID(value)) {
+ const uuid = await this.ensureMeta(value);
+ comp.data[field] = uuid;
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private resolveComponentRefs(comp: { type: string; data: Record<string, unknown> }): void {
+ const refs = getComponentRefFields(comp.type);
+ if (!refs || !comp.data) return;
+
+ for (const field of refs) {
+ const value = comp.data[field];
+ if (typeof value === 'string' && isUUID(value)) {
+ const path = this.getPath(value);
+ if (path) {
+ comp.data[field] = path;
+ }
+ }
+ }
+ }
+}
+
+// =============================================================================
+// Component → Asset Reference Field Registry
+// =============================================================================
+
+const COMPONENT_REF_FIELDS = new Map<string, string[]>([
+ ['Sprite', ['texture', 'material']],
+ ['SpineAnimation', ['skeletonPath', 'atlasPath', 'material']],
+ ['BitmapText', ['font']],
+ ['UIMask', ['texture']],
+]);
+
+export function getComponentRefFields(componentType: string): string[] | undefined {
+ return COMPONENT_REF_FIELDS.get(componentType);
+}
+
+export function registerComponentRefFields(componentType: string, fields: string[]): void {
+ COMPONENT_REF_FIELDS.set(componentType, fields);
+}
+
+// =============================================================================
+// Singleton
+// =============================================================================
+
+let instance: AssetDatabase | null = null;
+
+export function getAssetDatabase(): AssetDatabase {
+ if (!instance) {
+ instance = new AssetDatabase();
+ }
+ return instance;
+}
+
+export function resetAssetDatabase(): void {
+ instance = null;
+}
+
+// Backward-compatible aliases
+export { AssetDatabase as AssetLibrary };
+export const getAssetLibrary = getAssetDatabase;
+export const resetAssetLibrary = resetAssetDatabase;
diff --git a/editor/src/asset/AssetDependencyAnalyzer.ts b/editor/src/asset/AssetDependencyAnalyzer.ts
new file mode 100644
index 000000000..7e6a5ef70
--- /dev/null
+++ b/editor/src/asset/AssetDependencyAnalyzer.ts
@@ -0,0 +1,364 @@
+/**
+ * @file AssetDependencyAnalyzer.ts
+ * @brief Static analysis of asset dependencies across scenes, materials, atlases, and fonts
+ */
+
+import type { AssetDatabase } from './AssetDatabase';
+import { isUUID } from './AssetDatabase';
+import { looksLikeAssetPath } from './AssetTypes';
+import { joinPath, isAbsolutePath, getDirName } from '../utils/path';
+import type { NativeFS } from '../types/NativeFS';
+
+// =============================================================================
+// Types
+// =============================================================================
+
+export interface AssetRefScanner {
+ componentType: string;
+ extractRefs(data: Record<string, unknown>): string[];
+}
+
+export interface DependencyGraph {
+ dependencies: Map<string, Set<string>>;
+ dependents: Map<string, Set<string>>;
+ unreferenced: Set<string>;
+ broken: Map<string, string[]>;
+}
+
+// =============================================================================
+// Builtin Scanners
+// =============================================================================
+
+const builtinScanners: AssetRefScanner[] = [
+ {
+ componentType: 'Sprite',
+ extractRefs: (d) => [d.texture as string, d.material as string].filter(Boolean),
+ },
+ {
+ componentType: 'SpineAnimation',
+ extractRefs: (d) => [
+ d.skeletonPath as string,
+ d.atlasPath as string,
+ d.material as string,
+ ].filter(Boolean),
+ },
+ {
+ componentType: 'BitmapText',
+ extractRefs: (d) => [d.font as string].filter(Boolean),
+ },
+ {
+ componentType: 'UIMask',
+ extractRefs: (d) => [d.texture as string].filter(Boolean),
+ },
+];
+
+const customScanners: AssetRefScanner[] = [];
+
+export function registerRefScanner(scanner: AssetRefScanner): void {
+ customScanners.push(scanner);
+}
+
+function getAllScanners(): AssetRefScanner[] {
+ return [...builtinScanners, ...customScanners];
+}
+
+// =============================================================================
+// AssetDependencyAnalyzer
+// =============================================================================
+
+export class AssetDependencyAnalyzer {
+ private fs_: NativeFS;
+ private projectDir_: string;
+ private assetDb_: AssetDatabase;
+
+ constructor(fs: NativeFS, projectDir: string, assetDb: AssetDatabase) {
+ this.fs_ = fs;
+ this.projectDir_ = projectDir;
+ this.assetDb_ = assetDb;
+ }
+
+ async analyze(scenePaths: string[]): Promise<DependencyGraph> {
+ const dependencies = new Map<string, Set<string>>();
+ const dependents = new Map<string, Set<string>>();
+
+ for (const scenePath of scenePaths) {
+ const sceneUuid = this.assetDb_.getUuid(scenePath);
+ const sceneKey = sceneUuid ?? scenePath;
+
+ const fullPath = isAbsolutePath(scenePath)
+ ? scenePath
+ : joinPath(this.projectDir_, scenePath);
+
+ const content = await this.fs_.readFile(fullPath);
+ if (!content) continue;
+
+ try {
+ const scene = JSON.parse(content);
+ const refs = this.extractSceneRefs(scene);
+ const visited = new Set<string>();
+
+ for (const ref of refs) {
+ const resolvedRef = this.resolveRef(ref);
+ const refUuid = this.assetDb_.getUuid(resolvedRef) ?? resolvedRef;
+
+ this.addEdge(dependencies, dependents, sceneKey, refUuid);
+
+ await this.collectTransitiveRefs(resolvedRef, refUuid, dependencies, dependents, visited);
+ }
+ } catch {
+ continue;
+ }
+ }
+
+ const allUuids = new Set<string>();
+ for (const entry of this.assetDb_.getAllEntries()) {
+ allUuids.add(entry.uuid);
+ }
+
+ const referenced = new Set<string>();
+ for (const [, deps] of dependencies) {
+ for (const dep of deps) {
+ referenced.add(dep);
+ }
+ }
+ for (const key of dependencies.keys()) {
+ referenced.add(key);
+ }
+
+ const unreferenced = new Set<string>();
+ for (const uuid of allUuids) {
+ const entry = this.assetDb_.getEntry(uuid);
+ if (!entry) continue;
+ if (entry.type === 'json' && entry.path.endsWith('.esscene')) continue;
+ if (!referenced.has(uuid) && !dependents.has(uuid)) {
+ unreferenced.add(uuid);
+ }
+ }
+
+ const broken = new Map<string, string[]>();
+ for (const [source, deps] of dependencies) {
+ const missing: string[] = [];
+ for (const dep of deps) {
+ if (isUUID(dep) && !this.assetDb_.getEntry(dep)) {
+ missing.push(dep);
+ }
+ }
+ if (missing.length > 0) {
+ broken.set(source, missing);
+ }
+ }
+
+ return { dependencies, dependents, unreferenced, broken };
+ }
+
+ // =========================================================================
+ // Scene Ref Extraction (using registered scanners)
+ // =========================================================================
+
+ private extractSceneRefs(scene: Record<string, unknown>): string[] {
+ const refs: string[] = [];
+ const entities = scene.entities as Array<{
+ components: Array<{ type: string; data: Record<string, unknown> }>;
+ }> | undefined;
+
+ if (!entities) return refs;
+
+ const scanners = getAllScanners();
+ const scannerMap = new Map<string, AssetRefScanner>();
+ for (const s of scanners) {
+ scannerMap.set(s.componentType, s);
+ }
+
+ for (const entity of entities) {
+ for (const comp of entity.components || []) {
+ const scanner = scannerMap.get(comp.type);
+ if (scanner && comp.data) {
+ refs.push(...scanner.extractRefs(comp.data));
+ }
+ }
+ }
+
+ const textureMetadata = scene.textureMetadata as Record<string, unknown> | undefined;
+ if (textureMetadata) {
+ refs.push(...Object.keys(textureMetadata));
+ }
+
+ return refs;
+ }
+
+ // =========================================================================
+ // Transitive Reference Collection
+ // =========================================================================
+
+ private async collectTransitiveRefs(
+ resolvedPath: string,
+ uuid: string,
+ dependencies: Map<string, Set<string>>,
+ dependents: Map<string, Set<string>>,
+ visited: Set<string>
+ ): Promise<void> {
+ if (visited.has(resolvedPath)) return;
+ visited.add(resolvedPath);
+
+ if (resolvedPath.endsWith('.esmaterial')) {
+ await this.collectMaterialRefs(resolvedPath, uuid, dependencies, dependents, visited);
+ } else if (resolvedPath.endsWith('.atlas')) {
+ await this.collectAtlasRefs(resolvedPath, uuid, dependencies, dependents);
+ } else if (resolvedPath.endsWith('.bmfont') || resolvedPath.endsWith('.fnt')) {
+ await this.collectFontRefs(resolvedPath, uuid, dependencies, dependents);
+ }
+ }
+
+ private async collectMaterialRefs(
+ materialPath: string,
+ materialUuid: string,
+ dependencies: Map<string, Set<string>>,
+ dependents: Map<string, Set<string>>,
+ visited: Set<string>
+ ): Promise<void> {
+ const fullPath = isAbsolutePath(materialPath)
+ ? materialPath
+ : joinPath(this.projectDir_, materialPath);
+
+ const content = await this.fs_.readFile(fullPath);
+ if (!content) return;
+
+ try {
+ const material = JSON.parse(content);
+
+ if (typeof material.shader === 'string' && material.shader) {
+ const shaderPath = material.shader;
+ const shaderUuid = this.assetDb_.getUuid(shaderPath) ?? shaderPath;
+ this.addEdge(dependencies, dependents, materialUuid, shaderUuid);
+ }
+
+ if (material.properties && typeof material.properties === 'object') {
+ for (const value of Object.values(material.properties)) {
+ if (looksLikeAssetPath(value)) {
+ const texUuid = this.assetDb_.getUuid(value) ?? value;
+ this.addEdge(dependencies, dependents, materialUuid, texUuid);
+ }
+ }
+ }
+ } catch {
+ // Ignore parse errors
+ }
+ }
+
+ private async collectAtlasRefs(
+ atlasPath: string,
+ atlasUuid: string,
+ dependencies: Map<string, Set<string>>,
+ dependents: Map<string, Set<string>>
+ ): Promise<void> {
+ const fullPath = isAbsolutePath(atlasPath)
+ ? atlasPath
+ : joinPath(this.projectDir_, atlasPath);
+
+ const content = await this.fs_.readFile(fullPath);
+ if (!content) return;
+
+ const atlasDir = getDirName(atlasPath);
+ for (const rawLine of content.split('\n')) {
+ const line = rawLine.trim();
+ if (line && line.indexOf(':') === -1 && (/\.png$/i.test(line) || /\.jpg$/i.test(line))) {
+ const texturePath = atlasDir ? `${atlasDir}/${line}` : line;
+ const texUuid = this.assetDb_.getUuid(texturePath) ?? texturePath;
+ this.addEdge(dependencies, dependents, atlasUuid, texUuid);
+ }
+ }
+ }
+
+ private async collectFontRefs(
+ fontPath: string,
+ fontUuid: string,
+ dependencies: Map<string, Set<string>>,
+ dependents: Map<string, Set<string>>
+ ): Promise<void> {
+ const fullPath = isAbsolutePath(fontPath)
+ ? fontPath
+ : joinPath(this.projectDir_, fontPath);
+
+ const content = await this.fs_.readFile(fullPath);
+ if (!content) return;
+
+ if (fontPath.endsWith('.bmfont')) {
+ try {
+ const json = JSON.parse(content);
+ if (json.fntFile) {
+ const dir = getDirName(fontPath);
+ const fntPath = dir ? `${dir}/${json.fntFile}` : json.fntFile;
+ const fntUuid = this.assetDb_.getUuid(fntPath) ?? fntPath;
+ this.addEdge(dependencies, dependents, fontUuid, fntUuid);
+ }
+ } catch {
+ // ignore
+ }
+ } else {
+ const pageMatch = content.match(/file="([^"]+)"/);
+ if (pageMatch) {
+ const dir = getDirName(fontPath);
+ const texPath = dir ? `${dir}/${pageMatch[1]}` : pageMatch[1];
+ const texUuid = this.assetDb_.getUuid(texPath) ?? texPath;
+ this.addEdge(dependencies, dependents, fontUuid, texUuid);
+ }
+ }
+ }
+
+ // =========================================================================
+ // Helpers
+ // =========================================================================
+
+ private resolveRef(ref: string): string {
+ if (isUUID(ref)) {
+ return this.assetDb_.getPath(ref) ?? ref;
+ }
+ return ref;
+ }
+
+ private addEdge(
+ dependencies: Map<string, Set<string>>,
+ dependents: Map<string, Set<string>>,
+ from: string,
+ to: string
+ ): void {
+ if (!dependencies.has(from)) {
+ dependencies.set(from, new Set());
+ }
+ dependencies.get(from)!.add(to);
+
+ if (!dependents.has(to)) {
+ dependents.set(to, new Set());
+ }
+ dependents.get(to)!.add(from);
+ }
+}
+
+// =============================================================================
+// Convenience: collect referenced assets from scenes (replaces AssetReferenceCollector)
+// =============================================================================
+
+export async function collectReferencedAssets(
+ fs: NativeFS,
+ projectDir: string,
+ assetDb: AssetDatabase,
+ scenePaths: string[]
+): Promise<Set<string>> {
+ const analyzer = new AssetDependencyAnalyzer(fs, projectDir, assetDb);
+ const graph = await analyzer.analyze(scenePaths);
+
+ const result = new Set<string>();
+
+ for (const [, deps] of graph.dependencies) {
+ for (const uuid of deps) {
+ const path = assetDb.getPath(uuid);
+ if (path) {
+ result.add(path);
+ } else if (!isUUID(uuid)) {
+ result.add(uuid);
+ }
+ }
+ }
+
+ return result;
+}
diff --git a/editor/src/asset/AssetGroup.ts b/editor/src/asset/AssetGroup.ts
new file mode 100644
index 000000000..331f06cbd
--- /dev/null
+++ b/editor/src/asset/AssetGroup.ts
@@ -0,0 +1,196 @@
+/**
+ * @file AssetGroup.ts
+ * @brief Asset group and label management service
+ */
+
+import type { NativeFS } from '../types/NativeFS';
+import { joinPath } from '../utils/path';
+
+// =============================================================================
+// Types
+// =============================================================================
+
+export type BundleMode = 'together' | 'separate' | 'perFile';
+
+export interface AssetGroupDef {
+ name: string;
+ description: string;
+ bundleMode: BundleMode;
+ labels: string[];
+ include: string[];
+}
+
+export interface AssetGroupsConfig {
+ version: '1.0';
+ groups: AssetGroupDef[];
+ allLabels: string[];
+}
+
+// =============================================================================
+// Defaults
+// =============================================================================
+
+const CONFIG_PATH = '.esengine/asset-groups.json';
+
+function createDefaultConfig(): AssetGroupsConfig {
+ return {
+ version: '1.0',
+ groups: [
+ {
+ name: 'default',
+ description: 'Default group for all assets',
+ bundleMode: 'together',
+ labels: [],
+ include: ['assets/**/*'],
+ },
+ ],
+ allLabels: [],
+ };
+}
+
+// =============================================================================
+// AssetGroupService
+// =============================================================================
+
+export class AssetGroupService {
+ private config_: AssetGroupsConfig;
+ private fs_: NativeFS;
+ private projectDir_: string;
+
+ constructor(projectDir: string, fs: NativeFS) {
+ this.projectDir_ = projectDir;
+ this.fs_ = fs;
+ this.config_ = createDefaultConfig();
+ }
+
+ get config(): Readonly<AssetGroupsConfig> {
+ return this.config_;
+ }
+
+ get groups(): readonly AssetGroupDef[] {
+ return this.config_.groups;
+ }
+
+ get allLabels(): readonly string[] {
+ return this.config_.allLabels;
+ }
+
+ async load(): Promise<void> {
+ const fullPath = joinPath(this.projectDir_, CONFIG_PATH);
+ const content = await this.fs_.readFile(fullPath);
+ if (!content) {
+ this.config_ = createDefaultConfig();
+ return;
+ }
+
+ try {
+ const data = JSON.parse(content);
+ this.config_ = {
+ version: '1.0',
+ groups: Array.isArray(data.groups) ? data.groups : createDefaultConfig().groups,
+ allLabels: Array.isArray(data.allLabels) ? data.allLabels : [],
+ };
+ } catch {
+ this.config_ = createDefaultConfig();
+ }
+ }
+
+ async save(): Promise<void> {
+ const dirPath = joinPath(this.projectDir_, '.esengine');
+ await this.fs_.createDirectory(dirPath);
+ const fullPath = joinPath(this.projectDir_, CONFIG_PATH);
+ await this.fs_.writeFile(fullPath, JSON.stringify(this.config_, null, 4));
+ }
+
+ // =========================================================================
+ // Group CRUD
+ // =========================================================================
+
+ getGroup(name: string): AssetGroupDef | undefined {
+ return this.config_.groups.find(g => g.name === name);
+ }
+
+ addGroup(group: AssetGroupDef): void {
+ if (this.config_.groups.some(g => g.name === group.name)) return;
+ this.config_.groups.push(group);
+ }
+
+ removeGroup(name: string): void {
+ if (name === 'default') return;
+ this.config_.groups = this.config_.groups.filter(g => g.name !== name);
+ }
+
+ renameGroup(oldName: string, newName: string): void {
+ if (oldName === 'default') return;
+ const group = this.config_.groups.find(g => g.name === oldName);
+ if (group) {
+ group.name = newName;
+ }
+ }
+
+ updateGroup(name: string, updates: Partial<Omit<AssetGroupDef, 'name'>>): void {
+ const group = this.config_.groups.find(g => g.name === name);
+ if (!group) return;
+ if (updates.description !== undefined) group.description = updates.description;
+ if (updates.bundleMode !== undefined) group.bundleMode = updates.bundleMode;
+ if (updates.labels !== undefined) group.labels = updates.labels;
+ if (updates.include !== undefined) group.include = updates.include;
+ }
+
+ // =========================================================================
+ // Label CRUD
+ // =========================================================================
+
+ addLabel(label: string): void {
+ if (!this.config_.allLabels.includes(label)) {
+ this.config_.allLabels.push(label);
+ }
+ }
+
+ removeLabel(label: string): void {
+ this.config_.allLabels = this.config_.allLabels.filter(l => l !== label);
+ for (const group of this.config_.groups) {
+ group.labels = group.labels.filter(l => l !== label);
+ }
+ }
+
+ // =========================================================================
+ // Asset → Group Resolution
+ // =========================================================================
+
+ resolveGroup(assetPath: string, metaGroup: string | undefined): string {
+ if (metaGroup && metaGroup !== 'default') {
+ if (this.config_.groups.some(g => g.name === metaGroup)) {
+ return metaGroup;
+ }
+ }
+
+ for (const group of this.config_.groups) {
+ if (group.name === 'default') continue;
+ if (this.matchesIncludes(assetPath, group.include)) {
+ return group.name;
+ }
+ }
+
+ return 'default';
+ }
+
+ private matchesIncludes(assetPath: string, patterns: string[]): boolean {
+ for (const pattern of patterns) {
+ if (this.globMatch(assetPath, pattern)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private globMatch(path: string, pattern: string): boolean {
+ const regexStr = pattern
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
+ .replace(/\*\*/g, '§')
+ .replace(/\*/g, '[^/]*')
+ .replace(/§/g, '.*')
+ .replace(/\?/g, '.');
+ return new RegExp(`^${regexStr}$`).test(path);
+ }
+}
diff --git a/editor/src/panels/AddressablePanel.ts b/editor/src/panels/AddressablePanel.ts
new file mode 100644
index 000000000..276a86521
--- /dev/null
+++ b/editor/src/panels/AddressablePanel.ts
@@ -0,0 +1,893 @@
+/**
+ * @file AddressablePanel.ts
+ * @brief Addressable asset management panel with groups, labels, and dependency analysis
+ */
+
+import type { EditorStore, AssetType } from '../store/EditorStore';
+import type { PanelInstance } from './PanelRegistry';
+import { icons } from '../utils/icons';
+import { getAssetDatabase, type AssetEntry } from '../asset/AssetDatabase';
+import type { AssetGroupService, AssetGroupDef, BundleMode } from '../asset/AssetGroup';
+import { AssetDependencyAnalyzer } from '../asset/AssetDependencyAnalyzer';
+import { getEditorInstance, getEditorContext } from '../context/EditorContext';
+import { showInputDialog, showConfirmDialog } from '../ui/dialog';
+import { showContextMenu } from '../ui/ContextMenu';
+import { showErrorToast, showSuccessToast } from '../ui/Toast';
+
+const LABEL_COLORS = [
+ '#61afef', '#e06c75', '#98c379', '#d19a66',
+ '#c678dd', '#56b6c2', '#e5c07b', '#be5046',
+];
+
+// =============================================================================
+// AddressablePanel
+// =============================================================================
+
+export class AddressablePanel implements PanelInstance {
+ private container_: HTMLElement;
+ private store_: EditorStore;
+ private groupListEl_: HTMLElement | null = null;
+ private groupConfigEl_: HTMLElement | null = null;
+ private labelListEl_: HTMLElement | null = null;
+ private assetTableEl_: HTMLElement | null = null;
+ private statusBarEl_: HTMLElement | null = null;
+ private unreferencedEl_: HTMLElement | null = null;
+ private selectedGroup_: string = 'default';
+ private filterLabels_ = new Set<string>();
+ private searchQuery_ = '';
+ private sortColumn_: 'name' | 'address' | 'type' | 'size' = 'name';
+ private sortAsc_ = true;
+ private selectedUuids_ = new Set<string>();
+ private lastClickedUuid_: string | null = null;
+ private currentEntries_: AssetEntry[] = [];
+ private groupConfigExpanded_ = false;
+ private unreferencedUuids_: string[] = [];
+ private analyzing_ = false;
+
+ constructor(container: HTMLElement, store: EditorStore) {
+ this.container_ = container;
+ this.store_ = store;
+ this.buildLayout();
+ this.render();
+ }
+
+ dispose(): void {
+ this.container_.innerHTML = '';
+ }
+
+ onShow(): void {
+ this.render();
+ }
+
+ // =========================================================================
+ // Layout
+ // =========================================================================
+
+ private buildLayout(): void {
+ this.container_.className = 'es-addressable-panel';
+ this.container_.innerHTML = `
+ <div class="es-panel-header">
+ <span class="es-panel-title">${icons.layers(14)} Addressable Assets</span>
+ <div class="es-panel-actions">
+ <button class="es-btn es-btn-icon es-addr-refresh" title="Refresh">${icons.refresh(14)}</button>
+ </div>
+ </div>
+ <div class="es-addressable-body">
+ <div class="es-addressable-sidebar">
+ <div class="es-addressable-sidebar-section">
+ <div class="es-sidebar-header">
+ <span>Groups</span>
+ <button class="es-btn es-btn-icon es-addr-add-group" title="Add Group">${icons.plus(10)}</button>
+ </div>
+ <div class="es-addr-group-list"></div>
+ </div>
+ <div class="es-addressable-sidebar-section">
+ <div class="es-sidebar-header">
+ <span>Labels</span>
+ <button class="es-btn es-btn-icon es-addr-add-label" title="Add Label">${icons.plus(10)}</button>
+ </div>
+ <div class="es-addr-label-list"></div>
+ </div>
+ <div class="es-addr-group-config"></div>
+ </div>
+ <div class="es-addressable-main">
+ <div class="es-addressable-toolbar">
+ <input type="text" class="es-input es-addr-search" placeholder="Search assets..." />
+ <button class="es-btn es-btn-small es-addr-analyze" title="Analyze unreferenced assets">Analyze</button>
+ </div>
+ <div class="es-addr-asset-table"></div>
+ <div class="es-addr-unreferenced" style="display:none"></div>
+ </div>
+ </div>
+ <div class="es-addressable-status"></div>
+ `;
+
+ this.groupListEl_ = this.container_.querySelector('.es-addr-group-list');
+ this.groupConfigEl_ = this.container_.querySelector('.es-addr-group-config');
+ this.labelListEl_ = this.container_.querySelector('.es-addr-label-list');
+ this.assetTableEl_ = this.container_.querySelector('.es-addr-asset-table');
+ this.statusBarEl_ = this.container_.querySelector('.es-addressable-status');
+ this.unreferencedEl_ = this.container_.querySelector('.es-addr-unreferenced');
+
+ this.container_.querySelector('.es-addr-refresh')?.addEventListener('click', () => this.render());
+ this.container_.querySelector('.es-addr-add-group')?.addEventListener('click', () => this.addGroup());
+ this.container_.querySelector('.es-addr-add-label')?.addEventListener('click', () => this.addLabel());
+ this.container_.querySelector('.es-addr-analyze')?.addEventListener('click', () => this.analyzeUnreferenced());
+
+ const searchInput = this.container_.querySelector('.es-addr-search') as HTMLInputElement;
+ searchInput?.addEventListener('input', () => {
+ this.searchQuery_ = searchInput.value.toLowerCase();
+ this.renderAssetTable();
+ });
+
+ this.assetTableEl_?.addEventListener('dblclick', (e) => {
+ const row = (e.target as HTMLElement).closest('.es-addr-table-row') as HTMLElement | null;
+ if (!row) return;
+ const uuid = row.dataset.uuid;
+ if (!uuid) return;
+ this.selectAssetInStore(uuid);
+ });
+ }
+
+ // =========================================================================
+ // Render
+ // =========================================================================
+
+ private render(): void {
+ this.renderGroupList();
+ this.renderLabelList();
+ this.renderAssetTable();
+ this.renderGroupConfig();
+ this.renderStatusBar();
+ }
+
+ private renderGroupList(): void {
+ if (!this.groupListEl_) return;
+ const groupService = this.getGroupService();
+ if (!groupService) {
+ this.groupListEl_.innerHTML = '<div class="es-muted">No project loaded</div>';
+ return;
+ }
+
+ const groups = groupService.groups;
+ this.groupListEl_.innerHTML = '';
+
+ const db = getAssetDatabase();
+ for (const group of groups) {
+ const count = db.getUuidsByGroup(group.name).size;
+ const item = document.createElement('div');
+ item.className = `es-addr-group-item${group.name === this.selectedGroup_ ? ' es-selected' : ''}`;
+ item.innerHTML = `<span class="es-addr-group-dot"></span> ${this.escapeHtml(group.name)}<span class="es-addr-group-count">${count}</span>`;
+ item.addEventListener('click', () => {
+ this.selectedGroup_ = group.name;
+ this.renderGroupList();
+ this.renderAssetTable();
+ this.renderGroupConfig();
+ });
+ item.addEventListener('contextmenu', (e) => {
+ e.preventDefault();
+ this.showGroupContextMenu(e as MouseEvent, group);
+ });
+
+ item.addEventListener('dragover', (e) => {
+ if (e.dataTransfer?.types.includes('application/esengine-addressable')) {
+ e.preventDefault();
+ item.classList.add('es-drag-over');
+ }
+ });
+ item.addEventListener('dragleave', () => {
+ item.classList.remove('es-drag-over');
+ });
+ item.addEventListener('drop', (e) => {
+ e.preventDefault();
+ item.classList.remove('es-drag-over');
+ const data = e.dataTransfer?.getData('application/esengine-addressable');
+ if (!data) return;
+ try {
+ const uuids: string[] = JSON.parse(data);
+ this.moveAssetsToGroup(uuids, group.name);
+ } catch { /* ignore */ }
+ });
+
+ this.groupListEl_.appendChild(item);
+ }
+ }
+
+ private renderLabelList(): void {
+ if (!this.labelListEl_) return;
+ const groupService = this.getGroupService();
+ if (!groupService) {
+ this.labelListEl_.innerHTML = '';
+ return;
+ }
+
+ const labels = groupService.allLabels;
+ this.labelListEl_.innerHTML = '';
+
+ for (const label of labels) {
+ const color = this.getLabelColor(label);
+ const item = document.createElement('div');
+ item.className = 'es-addr-label-item';
+ const checked = this.filterLabels_.has(label);
+ item.innerHTML = `
+ <label class="es-addr-label-check">
+ <input type="checkbox" ${checked ? 'checked' : ''} />
+ <span class="es-addr-label-dot" style="background:${color}"></span>
+ <span>${this.escapeHtml(label)}</span>
+ </label>
+ `;
+ const checkbox = item.querySelector('input')!;
+ checkbox.addEventListener('change', () => {
+ if (checkbox.checked) {
+ this.filterLabels_.add(label);
+ } else {
+ this.filterLabels_.delete(label);
+ }
+ this.renderAssetTable();
+ });
+ item.addEventListener('contextmenu', (e) => {
+ e.preventDefault();
+ this.showLabelContextMenu(e as MouseEvent, label);
+ });
+ this.labelListEl_.appendChild(item);
+ }
+ }
+
+ private renderAssetTable(): void {
+ if (!this.assetTableEl_) return;
+ const db = getAssetDatabase();
+ const uuids = db.getUuidsByGroup(this.selectedGroup_);
+
+ let entries: AssetEntry[] = [];
+ for (const uuid of uuids) {
+ const entry = db.getEntry(uuid);
+ if (!entry) continue;
+
+ if (this.filterLabels_.size > 0) {
+ let hasLabel = false;
+ for (const label of this.filterLabels_) {
+ if (entry.labels.has(label)) {
+ hasLabel = true;
+ break;
+ }
+ }
+ if (!hasLabel) continue;
+ }
+
+ if (this.searchQuery_) {
+ const name = entry.path.split('/').pop() || '';
+ const addr = entry.address || '';
+ if (!name.toLowerCase().includes(this.searchQuery_) &&
+ !addr.toLowerCase().includes(this.searchQuery_)) {
+ continue;
+ }
+ }
+
+ entries.push(entry);
+ }
+
+ entries.sort((a, b) => {
+ let cmp = 0;
+ switch (this.sortColumn_) {
+ case 'name': {
+ const nameA = a.path.split('/').pop() || '';
+ const nameB = b.path.split('/').pop() || '';
+ cmp = nameA.localeCompare(nameB);
+ break;
+ }
+ case 'address':
+ cmp = (a.address || '').localeCompare(b.address || '');
+ break;
+ case 'type':
+ cmp = a.type.localeCompare(b.type);
+ break;
+ case 'size':
+ cmp = a.fileSize - b.fileSize;
+ break;
+ }
+ return this.sortAsc_ ? cmp : -cmp;
+ });
+
+ this.currentEntries_ = entries;
+
+ const sortIcon = (col: string) => {
+ if (this.sortColumn_ !== col) return '';
+ return `<span class="es-addr-sort-icon">${this.sortAsc_ ? '▲' : '▼'}</span>`;
+ };
+
+ const headerHtml = `
+ <div class="es-addr-table-header">
+ <span class="es-addr-col-name${this.sortColumn_ === 'name' ? ' es-sorted' : ''}" data-col="name">Name${sortIcon('name')}</span>
+ <span class="es-addr-col-address${this.sortColumn_ === 'address' ? ' es-sorted' : ''}" data-col="address">Address${sortIcon('address')}</span>
+ <span class="es-addr-col-labels">Labels</span>
+ <span class="es-addr-col-type${this.sortColumn_ === 'type' ? ' es-sorted' : ''}" data-col="type">Type${sortIcon('type')}</span>
+ <span class="es-addr-col-size${this.sortColumn_ === 'size' ? ' es-sorted' : ''}" data-col="size">Size${sortIcon('size')}</span>
+ </div>
+ `;
+
+ const rowsHtml = entries.map(entry => {
+ const name = entry.path.split('/').pop() || '';
+ const labelsHtml = [...entry.labels].map(l => {
+ const color = this.getLabelColor(l);
+ return `<span class="es-addr-tag" style="--tag-color: ${color}">${this.escapeHtml(l)}</span>`;
+ }).join('');
+ const size = this.formatSize(entry.fileSize);
+ const selected = this.selectedUuids_.has(entry.uuid);
+ return `
+ <div class="es-addr-table-row${selected ? ' es-selected' : ''}" data-uuid="${entry.uuid}" draggable="true">
+ <span class="es-addr-col-name" title="${this.escapeHtml(entry.path)}">${this.escapeHtml(name)}</span>
+ <span class="es-addr-col-address">${this.escapeHtml(entry.address || '')}</span>
+ <span class="es-addr-col-labels">${labelsHtml}</span>
+ <span class="es-addr-col-type">${entry.type}</span>
+ <span class="es-addr-col-size">${size}</span>
+ </div>
+ `;
+ }).join('');
+
+ const bodyContent = entries.length > 0
+ ? `<div class="es-addr-table-body">${rowsHtml}</div>`
+ : `<div class="es-addr-empty">No assets in this group</div>`;
+ this.assetTableEl_.innerHTML = headerHtml + bodyContent;
+
+ const sortHeaders = this.assetTableEl_.querySelectorAll('[data-col]');
+ sortHeaders.forEach(el => {
+ el.addEventListener('click', () => {
+ const col = (el as HTMLElement).dataset.col as typeof this.sortColumn_;
+ if (this.sortColumn_ === col) {
+ this.sortAsc_ = !this.sortAsc_;
+ } else {
+ this.sortColumn_ = col;
+ this.sortAsc_ = true;
+ }
+ this.renderAssetTable();
+ });
+ });
+
+ const rows = this.assetTableEl_.querySelectorAll('.es-addr-table-row');
+ rows.forEach(row => {
+ row.addEventListener('click', (e) => {
+ const uuid = (row as HTMLElement).dataset.uuid;
+ if (!uuid) return;
+ const me = e as MouseEvent;
+
+ if (me.shiftKey && this.lastClickedUuid_) {
+ const idxA = this.currentEntries_.findIndex(en => en.uuid === this.lastClickedUuid_);
+ const idxB = this.currentEntries_.findIndex(en => en.uuid === uuid);
+ if (idxA >= 0 && idxB >= 0) {
+ const lo = Math.min(idxA, idxB);
+ const hi = Math.max(idxA, idxB);
+ if (!me.ctrlKey && !me.metaKey) {
+ this.selectedUuids_.clear();
+ }
+ for (let i = lo; i <= hi; i++) {
+ this.selectedUuids_.add(this.currentEntries_[i].uuid);
+ }
+ }
+ } else if (me.ctrlKey || me.metaKey) {
+ if (this.selectedUuids_.has(uuid)) {
+ this.selectedUuids_.delete(uuid);
+ } else {
+ this.selectedUuids_.add(uuid);
+ }
+ this.lastClickedUuid_ = uuid;
+ } else {
+ this.selectedUuids_.clear();
+ this.selectedUuids_.add(uuid);
+ this.lastClickedUuid_ = uuid;
+ }
+
+ rows.forEach(r => r.classList.toggle('es-selected',
+ this.selectedUuids_.has((r as HTMLElement).dataset.uuid!)));
+ this.renderStatusBar();
+
+ if (this.selectedUuids_.size === 1) {
+ this.selectAssetInStore([...this.selectedUuids_][0]);
+ }
+ });
+
+ row.addEventListener('contextmenu', (e) => {
+ e.preventDefault();
+ const uuid = (row as HTMLElement).dataset.uuid;
+ if (!uuid) return;
+ if (!this.selectedUuids_.has(uuid)) {
+ this.selectedUuids_.clear();
+ this.selectedUuids_.add(uuid);
+ this.lastClickedUuid_ = uuid;
+ rows.forEach(r => r.classList.toggle('es-selected',
+ this.selectedUuids_.has((r as HTMLElement).dataset.uuid!)));
+ }
+ this.showAssetContextMenu(e as MouseEvent);
+ });
+
+ row.addEventListener('dragstart', (e) => {
+ const uuid = (row as HTMLElement).dataset.uuid;
+ if (!uuid) return;
+ if (!this.selectedUuids_.has(uuid)) {
+ this.selectedUuids_.clear();
+ this.selectedUuids_.add(uuid);
+ rows.forEach(r => r.classList.toggle('es-selected',
+ this.selectedUuids_.has((r as HTMLElement).dataset.uuid!)));
+ }
+ (e as DragEvent).dataTransfer?.setData(
+ 'application/esengine-addressable',
+ JSON.stringify([...this.selectedUuids_])
+ );
+ (row as HTMLElement).classList.add('es-dragging');
+ });
+
+ row.addEventListener('dragend', () => {
+ (row as HTMLElement).classList.remove('es-dragging');
+ });
+ });
+ }
+
+ private renderGroupConfig(): void {
+ if (!this.groupConfigEl_) return;
+ const groupService = this.getGroupService();
+ if (!groupService || !this.groupConfigExpanded_) {
+ this.groupConfigEl_.innerHTML = '';
+ if (!this.groupConfigExpanded_) {
+ this.groupConfigEl_.innerHTML = `
+ <div class="es-addr-config-toggle" title="Show group config">▸ Config</div>
+ `;
+ this.groupConfigEl_.querySelector('.es-addr-config-toggle')?.addEventListener('click', () => {
+ this.groupConfigExpanded_ = true;
+ this.renderGroupConfig();
+ });
+ }
+ return;
+ }
+
+ const group = groupService.getGroup(this.selectedGroup_);
+ if (!group) {
+ this.groupConfigEl_.innerHTML = '';
+ return;
+ }
+
+ const bundleOptions = (['together', 'separate', 'perFile'] as BundleMode[])
+ .map(m => `<option value="${m}"${m === group.bundleMode ? ' selected' : ''}>${m}</option>`)
+ .join('');
+
+ const includeHtml = group.include.length > 0
+ ? group.include.map(p => `<div class="es-addr-include-item">${this.escapeHtml(p)}</div>`).join('')
+ : '<div class="es-muted">No patterns</div>';
+
+ this.groupConfigEl_.innerHTML = `
+ <div class="es-addr-config-toggle" title="Hide group config">▾ Config: ${this.escapeHtml(group.name)}</div>
+ <div class="es-addr-group-config-body">
+ <div class="es-addr-config-field">
+ <span class="es-addr-config-label">Description</span>
+ <input type="text" class="es-input es-addr-config-desc" value="${this.escapeHtml(group.description)}" placeholder="Group description" />
+ </div>
+ <div class="es-addr-config-field">
+ <span class="es-addr-config-label">Bundle Mode</span>
+ <select class="es-input es-addr-config-bundle">${bundleOptions}</select>
+ </div>
+ <div class="es-addr-config-field">
+ <span class="es-addr-config-label">Include Patterns</span>
+ <div class="es-addr-include-list">${includeHtml}</div>
+ </div>
+ </div>
+ `;
+
+ this.groupConfigEl_.querySelector('.es-addr-config-toggle')?.addEventListener('click', () => {
+ this.groupConfigExpanded_ = !this.groupConfigExpanded_;
+ this.renderGroupConfig();
+ });
+
+ const descInput = this.groupConfigEl_.querySelector('.es-addr-config-desc') as HTMLInputElement;
+ descInput?.addEventListener('change', async () => {
+ groupService.updateGroup(this.selectedGroup_, { description: descInput.value });
+ await groupService.save();
+ });
+
+ const bundleSelect = this.groupConfigEl_.querySelector('.es-addr-config-bundle') as HTMLSelectElement;
+ bundleSelect?.addEventListener('change', async () => {
+ groupService.updateGroup(this.selectedGroup_, { bundleMode: bundleSelect.value as BundleMode });
+ await groupService.save();
+ });
+ }
+
+ private renderStatusBar(): void {
+ if (!this.statusBarEl_) return;
+ const db = getAssetDatabase();
+ const totalAssets = db.entryCount;
+ const totalGroups = db.getAllGroups().length;
+
+ let totalSize = 0;
+ for (const entry of db.getAllEntries()) {
+ totalSize += entry.fileSize;
+ }
+
+ const parts: string[] = [];
+ if (this.selectedUuids_.size > 0) {
+ parts.push(`${this.selectedUuids_.size} selected`);
+ }
+ parts.push(`Total: ${totalAssets} assets`);
+ parts.push(`${totalGroups} groups`);
+ parts.push(this.formatSize(totalSize));
+ if (this.unreferencedUuids_.length > 0) {
+ parts.push(`${this.unreferencedUuids_.length} unreferenced`);
+ }
+ this.statusBarEl_.textContent = parts.join(' · ');
+ }
+
+ private renderUnreferenced(): void {
+ if (!this.unreferencedEl_) return;
+
+ if (this.unreferencedUuids_.length === 0) {
+ this.unreferencedEl_.style.display = 'none';
+ return;
+ }
+
+ this.unreferencedEl_.style.display = '';
+ const db = getAssetDatabase();
+
+ const rowsHtml = this.unreferencedUuids_.map(uuid => {
+ const entry = db.getEntry(uuid);
+ if (!entry) return '';
+ const name = entry.path.split('/').pop() || '';
+ return `
+ <div class="es-addr-unreferenced-row" data-uuid="${uuid}" title="${this.escapeHtml(entry.path)}">
+ <span class="es-addr-col-name">${this.escapeHtml(name)}</span>
+ <span class="es-addr-col-type">${entry.type}</span>
+ <span class="es-addr-col-size">${this.formatSize(entry.fileSize)}</span>
+ </div>
+ `;
+ }).join('');
+
+ this.unreferencedEl_.innerHTML = `
+ <div class="es-addr-unreferenced-header">Unreferenced Assets (${this.unreferencedUuids_.length})</div>
+ <div class="es-addr-unreferenced-list">${rowsHtml}</div>
+ `;
+
+ this.unreferencedEl_.querySelectorAll('.es-addr-unreferenced-row').forEach(row => {
+ row.addEventListener('contextmenu', (e) => {
+ e.preventDefault();
+ const uuid = (row as HTMLElement).dataset.uuid;
+ if (!uuid) return;
+ this.showUnreferencedContextMenu(e as MouseEvent, uuid);
+ });
+ row.addEventListener('dblclick', () => {
+ const uuid = (row as HTMLElement).dataset.uuid;
+ if (!uuid) return;
+ const entry = db.getEntry(uuid);
+ if (entry) {
+ getEditorInstance()?.navigateToAsset(entry.path);
+ }
+ });
+ });
+ }
+
+ // =========================================================================
+ // Actions
+ // =========================================================================
+
+ private async addGroup(): Promise<void> {
+ const groupService = this.getGroupService();
+ if (!groupService) return;
+
+ const name = await showInputDialog({ title: 'New Group', placeholder: 'Group name' });
+ if (!name) return;
+
+ groupService.addGroup({
+ name,
+ description: '',
+ bundleMode: 'together',
+ labels: [],
+ include: [],
+ });
+ await groupService.save();
+ this.render();
+ }
+
+ private async addLabel(): Promise<void> {
+ const groupService = this.getGroupService();
+ if (!groupService) return;
+
+ const name = await showInputDialog({ title: 'New Label', placeholder: 'Label name' });
+ if (!name) return;
+
+ groupService.addLabel(name);
+ await groupService.save();
+ this.renderLabelList();
+ }
+
+ private async moveAssetsToGroup(uuids: string[], targetGroup: string): Promise<void> {
+ const db = getAssetDatabase();
+ for (const uuid of uuids) {
+ await db.updateMeta(uuid, { group: targetGroup });
+ }
+ this.render();
+ showSuccessToast(`Moved ${uuids.length} asset(s) to "${targetGroup}"`);
+ }
+
+ private async analyzeUnreferenced(): Promise<void> {
+ if (this.analyzing_) return;
+ const db = getAssetDatabase();
+ const fs = getEditorContext().fs;
+ const projectFilePath = getEditorInstance()?.projectPath;
+ if (!fs || !projectFilePath) {
+ showErrorToast('No project loaded');
+ return;
+ }
+ const projectDir = projectFilePath.replace(/[/\\][^/\\]+$/, '');
+
+ this.analyzing_ = true;
+ const btn = this.container_.querySelector('.es-addr-analyze') as HTMLButtonElement;
+ if (btn) btn.textContent = 'Analyzing...';
+
+ try {
+ const scenePaths: string[] = [];
+ for (const entry of db.getAllEntries()) {
+ if (entry.path.endsWith('.esscene')) {
+ scenePaths.push(entry.path);
+ }
+ }
+
+ const analyzer = new AssetDependencyAnalyzer(fs, projectDir, db);
+ const graph = await analyzer.analyze(scenePaths);
+ this.unreferencedUuids_ = [...graph.unreferenced];
+ this.renderUnreferenced();
+ this.renderStatusBar();
+ } catch (e) {
+ showErrorToast(`Analysis failed: ${e}`);
+ } finally {
+ this.analyzing_ = false;
+ if (btn) btn.textContent = 'Analyze';
+ }
+ }
+
+ private showGroupContextMenu(e: MouseEvent, group: AssetGroupDef): void {
+ showContextMenu({
+ x: e.clientX,
+ y: e.clientY,
+ items: [
+ {
+ label: 'Rename',
+ disabled: group.name === 'default',
+ onClick: async () => {
+ const newName = await showInputDialog({
+ title: 'Rename Group',
+ placeholder: 'New name',
+ defaultValue: group.name,
+ });
+ if (!newName || newName === group.name) return;
+ const gs = this.getGroupService();
+ if (!gs) return;
+ gs.renameGroup(group.name, newName);
+ await gs.save();
+ if (this.selectedGroup_ === group.name) {
+ this.selectedGroup_ = newName;
+ }
+ this.render();
+ },
+ },
+ {
+ label: 'Delete',
+ disabled: group.name === 'default',
+ onClick: async () => {
+ const confirmed = await showConfirmDialog({
+ title: 'Delete Group',
+ message: `Delete group "${group.name}"?`,
+ danger: true,
+ });
+ if (!confirmed) return;
+ const gs = this.getGroupService();
+ if (!gs) return;
+ gs.removeGroup(group.name);
+ await gs.save();
+ if (this.selectedGroup_ === group.name) {
+ this.selectedGroup_ = 'default';
+ }
+ this.render();
+ },
+ },
+ ],
+ });
+ }
+
+ private showLabelContextMenu(e: MouseEvent, label: string): void {
+ showContextMenu({
+ x: e.clientX,
+ y: e.clientY,
+ items: [
+ {
+ label: 'Delete',
+ onClick: async () => {
+ const confirmed = await showConfirmDialog({
+ title: 'Delete Label',
+ message: `Delete label "${label}"?`,
+ danger: true,
+ });
+ if (!confirmed) return;
+ const gs = this.getGroupService();
+ if (!gs) return;
+ gs.removeLabel(label);
+ await gs.save();
+ this.filterLabels_.delete(label);
+ this.render();
+ },
+ },
+ ],
+ });
+ }
+
+ private showAssetContextMenu(e: MouseEvent): void {
+ const db = getAssetDatabase();
+ const groupService = this.getGroupService();
+ const groups = groupService?.groups ?? [];
+ const uuids = [...this.selectedUuids_];
+ const isBatch = uuids.length > 1;
+
+ if (isBatch) {
+ const moveToItems = groups.map(g => ({
+ label: g.name,
+ onClick: () => this.moveAssetsToGroup(uuids, g.name),
+ }));
+
+ showContextMenu({
+ x: e.clientX,
+ y: e.clientY,
+ items: [
+ {
+ label: `Set Labels (${uuids.length})`,
+ onClick: async () => {
+ const input = await showInputDialog({
+ title: 'Set Labels (batch)',
+ placeholder: 'Labels (comma separated)',
+ });
+ if (input === null) return;
+ const newLabels = new Set(
+ input.split(',').map(s => s.trim()).filter(Boolean)
+ );
+ for (const uuid of uuids) {
+ await db.updateMeta(uuid, { labels: newLabels });
+ }
+ this.renderAssetTable();
+ },
+ },
+ {
+ label: `Move to Group (${uuids.length})`,
+ children: moveToItems,
+ },
+ ],
+ });
+ return;
+ }
+
+ const uuid = uuids[0];
+ const entry = db.getEntry(uuid);
+ if (!entry) return;
+
+ const moveToItems = groups
+ .filter(g => g.name !== entry.group)
+ .map(g => ({
+ label: g.name,
+ onClick: async () => {
+ await db.updateMeta(uuid, { group: g.name });
+ this.render();
+ },
+ }));
+
+ showContextMenu({
+ x: e.clientX,
+ y: e.clientY,
+ items: [
+ {
+ label: 'Set Address',
+ onClick: async () => {
+ const addr = await showInputDialog({
+ title: 'Set Address',
+ placeholder: 'Logical address',
+ defaultValue: entry.address ?? '',
+ });
+ if (addr === null) return;
+ await db.updateMeta(uuid, { address: addr || null });
+ this.renderAssetTable();
+ },
+ },
+ {
+ label: 'Edit Labels',
+ onClick: async () => {
+ const current = [...entry.labels].join(', ');
+ const input = await showInputDialog({
+ title: 'Edit Labels',
+ placeholder: 'Labels (comma separated)',
+ defaultValue: current,
+ });
+ if (input === null) return;
+ const newLabels = new Set(
+ input.split(',').map(s => s.trim()).filter(Boolean)
+ );
+ await db.updateMeta(uuid, { labels: newLabels });
+ this.renderAssetTable();
+ },
+ },
+ {
+ label: 'Move to Group',
+ children: moveToItems.length > 0 ? moveToItems : undefined,
+ disabled: moveToItems.length === 0,
+ },
+ {
+ label: 'Reveal in Content Browser',
+ onClick: () => {
+ getEditorInstance()?.navigateToAsset(entry.path);
+ },
+ },
+ ],
+ });
+ }
+
+ private showUnreferencedContextMenu(e: MouseEvent, uuid: string): void {
+ const groupService = this.getGroupService();
+ const groups = groupService?.groups ?? [];
+
+ const moveToItems = groups.map(g => ({
+ label: g.name,
+ onClick: () => this.moveAssetsToGroup([uuid], g.name),
+ }));
+
+ showContextMenu({
+ x: e.clientX,
+ y: e.clientY,
+ items: [
+ {
+ label: 'Move to Group',
+ children: moveToItems,
+ },
+ ],
+ });
+ }
+
+ // =========================================================================
+ // Helpers
+ // =========================================================================
+
+ private getGroupService(): AssetGroupService | null {
+ return getAssetDatabase().getGroupService();
+ }
+
+ private selectAssetInStore(uuid: string): void {
+ const db = getAssetDatabase();
+ const entry = db.getEntry(uuid);
+ if (!entry) return;
+ const projectDir = this.getProjectDir();
+ const fullPath = projectDir ? `${projectDir}/${entry.path}` : entry.path;
+ const name = entry.path.split('/').pop() || '';
+ this.store_.selectAsset({
+ path: fullPath,
+ type: entry.type as AssetType,
+ name,
+ });
+ }
+
+ private getProjectDir(): string | null {
+ const projectPath = getEditorInstance()?.projectPath;
+ if (!projectPath) return null;
+ return projectPath.replace(/[/\\][^/\\]+$/, '');
+ }
+
+ private getLabelColor(label: string): string {
+ let hash = 0;
+ for (let i = 0; i < label.length; i++) {
+ hash = ((hash << 5) - hash + label.charCodeAt(i)) | 0;
+ }
+ return LABEL_COLORS[Math.abs(hash) % LABEL_COLORS.length];
+ }
+
+ private formatSize(bytes: number): string {
+ if (bytes === 0) return '-';
+ if (bytes < 1024) return `${bytes} B`;
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
+ }
+
+ private escapeHtml(text: string): string {
+ return text
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+ }
+}
diff --git a/editor/src/panels/InspectorPanel.ts b/editor/src/panels/InspectorPanel.ts
index 76aedfe64..680b413d7 100644
--- a/editor/src/panels/InspectorPanel.ts
+++ b/editor/src/panels/InspectorPanel.ts
@@ -37,6 +37,7 @@ import {
} from '../shader/ShaderPropertyParser';
import { getEditorContext, getEditorInstance } from '../context/EditorContext';
import { AssetExportConfigService, type FolderExportMode } from '../builder/AssetCollector';
+import { getAssetDatabase } from '../asset/AssetDatabase';
import type { NativeFS } from '../types/NativeFS';
// =============================================================================
@@ -913,6 +914,7 @@ export class InspectorPanel {
this.hideMaterialPreview();
this.renderAssetHeader(asset);
+ this.renderAddressableSection(asset.path);
switch (asset.type) {
case 'image':
@@ -950,6 +952,129 @@ export class InspectorPanel {
this.contentContainer_.appendChild(header);
}
+ private resolveAssetEntry(assetPath: string) {
+ const db = getAssetDatabase();
+ const projectDir = this.getProjectDir();
+
+ if (projectDir && assetPath.startsWith(projectDir)) {
+ const rel = assetPath.substring(projectDir.length + 1);
+ const e = db.getEntryByPath(rel);
+ if (e) return e;
+ }
+
+ const direct = db.getEntryByPath(assetPath);
+ if (direct) return direct;
+
+ const normalized = assetPath.replace(/\\/g, '/');
+ const fileName = normalized.split('/').pop() || '';
+ for (const e of db.getAllEntries()) {
+ if (e.path === normalized || e.path.endsWith('/' + fileName)) {
+ return e;
+ }
+ }
+ return undefined;
+ }
+
+ private renderAddressableSection(assetPath: string): void {
+ const db = getAssetDatabase();
+
+ const entry = this.resolveAssetEntry(assetPath);
+ if (!entry) return;
+
+ const groupService = db.getGroupService();
+ const groups = groupService?.groups ?? [];
+ const allLabels = groupService?.allLabels ?? [];
+
+ const groupOptions = groups.map(g =>
+ `<option value="${this.escapeHtml(g.name)}"${g.name === entry.group ? ' selected' : ''}>${this.escapeHtml(g.name)}</option>`
+ ).join('');
+
+ const LABEL_COLORS = [
+ '#61afef', '#e06c75', '#98c379', '#d19a66',
+ '#c678dd', '#56b6c2', '#e5c07b', '#be5046',
+ ];
+ const hashLabel = (label: string) => {
+ let h = 0;
+ for (let i = 0; i < label.length; i++) {
+ h = ((h << 5) - h + label.charCodeAt(i)) | 0;
+ }
+ return LABEL_COLORS[Math.abs(h) % LABEL_COLORS.length];
+ };
+
+ const labelsHtml = allLabels.map(l => {
+ const checked = entry.labels.has(l);
+ const color = hashLabel(l);
+ return `
+ <label class="es-addr-label-toggle" style="--tag-color: ${color}">
+ <input type="checkbox" data-label="${this.escapeHtml(l)}" ${checked ? 'checked' : ''} />
+ <span>${this.escapeHtml(l)}</span>
+ </label>
+ `;
+ }).join('');
+
+ const section = document.createElement('div');
+ section.className = 'es-component-section es-collapsible es-expanded';
+ section.innerHTML = `
+ <div class="es-component-header es-collapsible-header">
+ <span class="es-collapse-icon">${icons.chevronDown(12)}</span>
+ <span class="es-component-icon">${icons.layers(14)}</span>
+ <span class="es-component-title">Addressable</span>
+ </div>
+ <div class="es-component-properties es-collapsible-content">
+ <div class="es-property-row">
+ <label class="es-property-label">Group</label>
+ <div class="es-property-editor">
+ <select class="es-input es-addr-inspector-group">${groupOptions}</select>
+ </div>
+ </div>
+ <div class="es-property-row">
+ <label class="es-property-label">Address</label>
+ <div class="es-property-editor">
+ <input type="text" class="es-input es-addr-inspector-address" value="${this.escapeHtml(entry.address ?? '')}" placeholder="Logical address" />
+ </div>
+ </div>
+ <div class="es-property-row es-property-row-top">
+ <label class="es-property-label">Labels</label>
+ <div class="es-property-editor es-addr-inspector-labels">
+ ${labelsHtml || '<span class="es-muted">No labels defined</span>'}
+ </div>
+ </div>
+ </div>
+ `;
+
+ const header = section.querySelector('.es-collapsible-header');
+ header?.addEventListener('click', () => {
+ section.classList.toggle('es-expanded');
+ });
+
+ const groupSelect = section.querySelector('.es-addr-inspector-group') as HTMLSelectElement;
+ groupSelect?.addEventListener('change', async () => {
+ await db.updateMeta(entry.uuid, { group: groupSelect.value });
+ });
+
+ const addressInput = section.querySelector('.es-addr-inspector-address') as HTMLInputElement;
+ addressInput?.addEventListener('change', async () => {
+ await db.updateMeta(entry.uuid, { address: addressInput.value || null });
+ });
+
+ section.querySelectorAll('.es-addr-inspector-labels input[type="checkbox"]').forEach(cb => {
+ cb.addEventListener('change', async () => {
+ const labelName = (cb as HTMLInputElement).dataset.label;
+ if (!labelName) return;
+ const currentLabels = new Set(entry.labels);
+ if ((cb as HTMLInputElement).checked) {
+ currentLabels.add(labelName);
+ } else {
+ currentLabels.delete(labelName);
+ }
+ entry.labels = currentLabels;
+ await db.updateMeta(entry.uuid, { labels: currentLabels });
+ });
+ });
+
+ this.contentContainer_.appendChild(section);
+ }
+
private async renderImageInspector(path: string): Promise<void> {
const fs = getNativeFS();
if (!fs) {
diff --git a/editor/src/panels/builtinPanels.ts b/editor/src/panels/builtinPanels.ts
index f07808a82..fd1e1494e 100644
--- a/editor/src/panels/builtinPanels.ts
+++ b/editor/src/panels/builtinPanels.ts
@@ -4,6 +4,7 @@ import { InspectorPanel } from './InspectorPanel';
import { SceneViewPanel } from './SceneViewPanel';
import { ContentBrowserPanel } from './ContentBrowserPanel';
import { OutputPanel } from './OutputPanel';
+import { AddressablePanel } from './AddressablePanel';
import { icons } from '../utils/icons';
export interface BuiltinPanelOptions {
@@ -63,4 +64,14 @@ export function registerBuiltinPanels(options: BuiltinPanelOptions): void {
defaultVisible: false,
factory: (c) => new OutputPanel(c),
});
+
+ registerPanel({
+ id: 'addressable',
+ title: 'Addressable',
+ icon: icons.layers(14),
+ position: 'bottom',
+ order: 2,
+ defaultVisible: true,
+ factory: (c, s) => new AddressablePanel(c, s),
+ });
}
diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.css
index 4e88175b4..92275fb45 100644
--- a/editor/src/styles/editor.css
+++ b/editor/src/styles/editor.css
@@ -4296,6 +4296,443 @@ svg {
margin-top: 8px;
}
+/* =============================================================================
+ * Addressable Panel
+ * ============================================================================= */
+
+.es-addressable-panel {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ background: var(--es-bg-primary);
+}
+
+.es-addressable-body {
+ display: flex;
+ flex: 1;
+ overflow: hidden;
+}
+
+.es-addressable-sidebar {
+ width: 180px;
+ min-width: 140px;
+ background: var(--es-bg-secondary);
+ border-right: 1px solid var(--es-border);
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+}
+
+.es-addressable-main {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+}
+
+.es-addressable-sidebar-section {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+}
+
+.es-addressable-sidebar-section + .es-addressable-sidebar-section {
+ border-top: 1px solid var(--es-border);
+}
+
+.es-sidebar-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 8px;
+ font-size: 10px;
+ text-transform: uppercase;
+ color: var(--es-text-secondary);
+ user-select: none;
+}
+
+.es-sidebar-header .es-btn-icon {
+ padding: 0;
+ min-width: 16px;
+ height: 16px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.es-addr-group-list,
+.es-addr-label-list {
+ overflow-y: auto;
+ flex: 1;
+ min-height: 0;
+}
+
+.es-addr-group-item {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ height: 28px;
+ padding: 0 12px 0 8px;
+ cursor: pointer;
+ user-select: none;
+ font-size: 12px;
+ border-left: 2px solid transparent;
+}
+
+.es-addr-group-item:hover {
+ background: var(--es-bg-hover);
+}
+
+.es-addr-group-item.es-selected {
+ background: rgba(209, 154, 102, 0.25);
+ border-left-color: #d19a66;
+ color: #d19a66;
+}
+
+.es-addr-group-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--es-accent);
+ flex-shrink: 0;
+}
+
+.es-addr-group-item.es-selected .es-addr-group-dot {
+ background: #d19a66;
+}
+
+.es-addr-group-count {
+ margin-left: auto;
+ font-size: 10px;
+ color: var(--es-text-secondary);
+ background: var(--es-bg-tertiary);
+ padding: 1px 6px;
+ border-radius: 8px;
+}
+
+.es-addr-label-item {
+ height: 24px;
+ display: flex;
+ align-items: center;
+ padding: 0 8px;
+}
+
+.es-addr-label-item:hover {
+ background: var(--es-bg-hover);
+}
+
+.es-addr-label-check {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 11px;
+ cursor: pointer;
+ user-select: none;
+}
+
+.es-addr-label-check input[type="checkbox"] {
+ accent-color: #d19a66;
+}
+
+.es-addressable-toolbar {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 8px;
+ background: var(--es-bg-secondary);
+ border-bottom: 1px solid var(--es-border);
+}
+
+.es-addr-search {
+ flex: 1;
+}
+
+.es-addr-asset-table {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ overflow: hidden;
+}
+
+.es-addr-table-header {
+ display: flex;
+ align-items: center;
+ height: 28px;
+ padding: 0 12px 0 8px;
+ background: var(--es-bg-secondary);
+ border-bottom: 1px solid var(--es-border);
+ font-size: 11px;
+ color: var(--es-text-secondary);
+ user-select: none;
+}
+
+.es-addr-table-header [data-col] {
+ cursor: pointer;
+}
+
+.es-addr-table-header [data-col]:hover {
+ color: var(--es-text-primary);
+}
+
+.es-addr-table-header [data-col].es-sorted {
+ color: var(--es-text-primary);
+}
+
+.es-addr-table-body {
+ flex: 1;
+ overflow-y: auto;
+}
+
+.es-addr-table-row {
+ display: flex;
+ align-items: center;
+ height: 28px;
+ padding: 0 12px 0 8px;
+ font-size: 12px;
+ cursor: default;
+}
+
+.es-addr-table-row:hover {
+ background: var(--es-bg-hover);
+}
+
+.es-addr-table-row:nth-child(even) {
+ background: rgba(255, 255, 255, 0.02);
+}
+
+.es-addr-table-row:nth-child(even):hover {
+ background: var(--es-bg-hover);
+}
+
+.es-addr-table-row.es-selected {
+ background: rgba(209, 154, 102, 0.2);
+}
+
+.es-addr-table-row.es-selected .es-addr-col-name {
+ color: #d19a66;
+}
+
+.es-addr-table-row:active {
+ background: rgba(255, 255, 255, 0.05);
+}
+
+.es-addr-col-name {
+ flex: 2;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.es-addr-col-address {
+ flex: 2;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.es-addr-col-labels {
+ flex: 1.5;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.es-addr-col-type {
+ width: 80px;
+ flex-shrink: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.es-addr-col-size {
+ width: 70px;
+ flex-shrink: 0;
+ text-align: right;
+}
+
+.es-addr-sort-icon {
+ margin-left: 2px;
+ font-size: 9px;
+}
+
+.es-addr-empty {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex: 1;
+ color: var(--es-text-secondary);
+ font-size: 12px;
+ padding: 24px;
+}
+
+.es-addr-tag {
+ display: inline-block;
+ padding: 0 5px;
+ margin-right: 3px;
+ border-radius: 3px;
+ font-size: 10px;
+ background: color-mix(in srgb, var(--tag-color) 20%, transparent);
+ color: var(--tag-color);
+ line-height: 16px;
+}
+
+.es-addr-label-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 2px 6px;
+ margin: 1px 3px 1px 0;
+ border-radius: 3px;
+ font-size: 11px;
+ cursor: pointer;
+ user-select: none;
+ background: color-mix(in srgb, var(--tag-color) 10%, transparent);
+ color: var(--es-text-secondary);
+ transition: background 0.1s;
+}
+
+.es-addr-label-toggle:has(input:checked) {
+ background: color-mix(in srgb, var(--tag-color) 25%, transparent);
+ color: var(--tag-color);
+}
+
+.es-addr-label-toggle input[type="checkbox"] {
+ width: 12px;
+ height: 12px;
+ accent-color: var(--tag-color);
+}
+
+.es-addr-inspector-labels {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0;
+}
+
+.es-property-row-top {
+ align-items: flex-start;
+}
+
+.es-addr-label-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ display: inline-block;
+ flex-shrink: 0;
+}
+
+.es-addr-table-row[draggable="true"] { cursor: grab; }
+.es-addr-table-row.es-dragging { opacity: 0.5; }
+
+.es-addr-group-item.es-drag-over {
+ background: rgba(97, 175, 239, 0.25);
+ border-left-color: #61afef;
+}
+
+.es-addr-config-toggle {
+ padding: 6px 8px;
+ font-size: 10px;
+ color: var(--es-text-secondary);
+ cursor: pointer;
+ user-select: none;
+ border-top: 1px solid var(--es-border);
+}
+
+.es-addr-config-toggle:hover {
+ color: var(--es-text-primary);
+}
+
+.es-addr-group-config-body {
+ padding: 4px 8px 8px;
+}
+
+.es-addr-config-field {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ margin-bottom: 6px;
+}
+
+.es-addr-config-label {
+ color: var(--es-text-secondary);
+ font-size: 10px;
+ text-transform: uppercase;
+}
+
+.es-addr-config-field .es-input {
+ font-size: 11px;
+ height: 22px;
+}
+
+.es-addr-include-list {
+ font-size: 11px;
+}
+
+.es-addr-include-item {
+ padding: 2px 0;
+ color: var(--es-text-primary);
+ font-family: monospace;
+ font-size: 10px;
+}
+
+.es-addr-unreferenced {
+ border-top: 1px solid var(--es-border);
+ background: var(--es-bg-secondary);
+ max-height: 200px;
+ overflow-y: auto;
+}
+
+.es-addr-unreferenced-header {
+ padding: 6px 12px;
+ font-size: 11px;
+ font-weight: 600;
+ color: #e06c75;
+ border-bottom: 1px solid var(--es-border);
+}
+
+.es-addr-unreferenced-list {
+ padding: 0;
+}
+
+.es-addr-unreferenced-row {
+ display: flex;
+ align-items: center;
+ height: 24px;
+ padding: 0 12px 0 8px;
+ font-size: 11px;
+ cursor: default;
+}
+
+.es-addr-unreferenced-row:hover {
+ background: var(--es-bg-hover);
+}
+
+.es-addr-unreferenced-row .es-addr-col-name {
+ flex: 2;
+}
+
+.es-addr-unreferenced-row .es-addr-col-type {
+ width: 60px;
+}
+
+.es-addr-unreferenced-row .es-addr-col-size {
+ width: 60px;
+}
+
+.es-addressable-status {
+ padding: 6px 12px;
+ font-size: 11px;
+ color: var(--es-text-secondary);
+ background: var(--es-bg-secondary);
+ border-top: 1px solid var(--es-border);
+}
+
+.es-muted {
+ color: var(--es-text-secondary);
+ font-size: 11px;
+ padding: 8px;
+}
+
/* =========================================================================
UIRect Editor
========================================================================= */