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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: semantic UI redesign for hierarchy and inspector panels
esengine1a45daac0dc8
diff --git a/editor/src/panels/hierarchy/EntityTemplates.ts b/editor/src/panels/hierarchy/EntityTemplates.tsnew file mode 100644index 000000000..406d94313--- /dev/null+++ b/editor/src/panels/hierarchy/EntityTemplates.ts@@ -0,0 +1,266 @@+import type { Entity } from 'esengine';+import { getInitialComponentData } from '../../schemas/ComponentSchemas';+import type { HierarchyState } from './HierarchyTypes';++interface ComponentEntry {+ type: string;+ defaults?: Record<string, unknown>;+}++interface EntityTemplateNode {+ name: string;+ ref?: string;+ components: ComponentEntry[];+ children?: EntityTemplateNode[];+}++interface EntityTemplate {+ root: EntityTemplateNode;+ bindings?: Record<string, string>;+}++function defineTemplate(root: EntityTemplateNode, bindings?: Record<string, string>): EntityTemplate {+ return { root, bindings };+}++export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {+ Button: defineTemplate({+ name: 'Button',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect' },+ { type: 'Interactable' },+ { type: 'Button' },+ ],+ }),++ Panel: defineTemplate({+ name: 'Panel',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect' },+ { type: 'UIMask' },+ ],+ }),++ Image: defineTemplate({+ name: 'Image',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect' },+ ],+ }),++ Toggle: defineTemplate({+ name: 'Toggle',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect', defaults: { size: { x: 24, y: 24 } } },+ { type: 'Interactable' },+ { type: 'Toggle' },+ ],+ children: [+ {+ name: 'Checkmark', ref: 'checkmark',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.2, g: 0.2, b: 0.2, a: 1 } } },+ { type: 'UIRect', defaults: { size: { x: 16, y: 16 } } },+ ],+ },+ ],+ }, {+ 'Toggle.graphicEntity': 'checkmark',+ }),++ ProgressBar: defineTemplate({+ name: 'ProgressBar',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.3, g: 0.3, b: 0.3, a: 1 } } },+ { type: 'UIRect', defaults: { size: { x: 200, y: 20 } } },+ { type: 'ProgressBar', defaults: { value: 0.5 } },+ ],+ children: [+ {+ name: 'Fill', ref: 'fill',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.2, g: 0.6, b: 1, a: 1 } } },+ { type: 'UIRect', defaults: { anchorMin: { x: 0, y: 0 }, anchorMax: { x: 0.5, y: 1 }, offsetMin: { x: 0, y: 0 }, offsetMax: { x: 0, y: 0 } } },+ ],+ },+ ],+ }, {+ 'ProgressBar.fillEntity': 'fill',+ }),++ ScrollView: defineTemplate({+ name: 'ScrollView',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.15, g: 0.15, b: 0.15, a: 1 } } },+ { type: 'UIRect', defaults: { size: { x: 300, y: 200 } } },+ { type: 'UIMask' },+ { type: 'Interactable' },+ { type: 'ScrollView' },+ ],+ children: [+ {+ name: 'Content', ref: 'content',+ components: [+ { type: 'Transform' },+ { type: 'UIRect', defaults: { anchorMin: { x: 0, y: 0 }, anchorMax: { x: 1, y: 1 }, offsetMin: { x: 0, y: 0 }, offsetMax: { x: 0, y: 0 } } },+ ],+ },+ ],+ }, {+ 'ScrollView.contentEntity': 'content',+ }),++ Slider: defineTemplate({+ name: 'Slider',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.3, g: 0.3, b: 0.3, a: 1 } } },+ { type: 'UIRect', defaults: { size: { x: 200, y: 20 } } },+ { type: 'Interactable' },+ { type: 'Slider', defaults: { value: 0.5 } },+ ],+ children: [+ {+ name: 'Fill', ref: 'fill',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { color: { r: 0.2, g: 0.6, b: 1, a: 1 } } },+ { type: 'UIRect', defaults: { anchorMin: { x: 0, y: 0 }, anchorMax: { x: 0.5, y: 1 }, offsetMin: { x: 0, y: 0 }, offsetMax: { x: 0, y: 0 } } },+ ],+ },+ {+ name: 'Handle', ref: 'handle',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect', defaults: { size: { x: 20, y: 20 } } },+ ],+ },+ ],+ }, {+ 'Slider.fillEntity': 'fill',+ 'Slider.handleEntity': 'handle',+ }),++ Dropdown: defineTemplate({+ name: 'Dropdown',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect', defaults: { size: { x: 160, y: 32 } } },+ { type: 'Interactable' },+ { type: 'Dropdown', defaults: { options: ['Option 1', 'Option 2', 'Option 3'] } },+ ],+ children: [+ {+ name: 'Label', ref: 'label',+ components: [+ { type: 'Transform' },+ { type: 'UIRect', defaults: { anchorMin: { x: 0, y: 0 }, anchorMax: { x: 1, y: 1 }, offsetMin: { x: 8, y: 0 }, offsetMax: { x: -8, y: 0 } } },+ { type: 'Text', defaults: { content: 'Select...' } },+ ],+ },+ {+ name: 'List', ref: 'list',+ components: [+ { type: 'Transform' },+ { type: 'Image', defaults: { enabled: false } },+ { type: 'UIRect', defaults: { size: { x: 160, y: 120 } } },+ ],+ },+ ],+ }, {+ 'Dropdown.labelEntity': 'label',+ 'Dropdown.listEntity': 'list',+ }),++ Tilemap: defineTemplate({+ name: 'Tilemap',+ components: [+ { type: 'Transform' },+ { type: 'Tilemap' },+ ],+ }),+};++export function instantiateTemplate(+ state: HierarchyState,+ templateName: string,+ parent: Entity | null,+): Entity | null {+ const template = ENTITY_TEMPLATES[templateName];+ if (!template) return null;++ const refMap = new Map<string, Entity>();++ const rootEntity = createNode(state, template.root, parent, refMap);++ if (template.bindings) {+ for (const [binding, ref] of Object.entries(template.bindings)) {+ const dotIdx = binding.indexOf('.');+ const compType = binding.substring(0, dotIdx);+ const fieldName = binding.substring(dotIdx + 1);+ const targetEntity = refMap.get(ref);+ if (targetEntity !== undefined) {+ state.store.updateProperty(+ rootEntity, compType, fieldName,+ undefined, targetEntity as number,+ );+ }+ }+ }++ state.store.selectEntity(rootEntity);+ return rootEntity;+}++function createNode(+ state: HierarchyState,+ node: EntityTemplateNode,+ parent: Entity | null,+ refMap: Map<string, Entity>,+): Entity {+ const entity = state.store.createEntity(node.name, parent);++ for (const comp of node.components) {+ let data = getInitialComponentData(comp.type);+ if (comp.defaults) {+ data = { ...data };+ for (const [key, val] of Object.entries(comp.defaults)) {+ if (val === undefined) {+ const initData = getInitialComponentData(comp.type);+ if (key in initData) {+ data[key] = initData[key];+ }+ } else {+ data[key] = val;+ }+ }+ }+ state.store.addComponent(entity, comp.type, data);+ }++ if (node.ref) {+ refMap.set(node.ref, entity);+ }++ if (node.children) {+ for (const child of node.children) {+ createNode(state, child, entity, refMap);+ }+ }++ return entity;+}diff --git a/editor/src/panels/hierarchy/HierarchyContextMenu.ts b/editor/src/panels/hierarchy/HierarchyContextMenu.tsindex 0e03d73fe..8b3b50666 100644--- a/editor/src/panels/hierarchy/HierarchyContextMenu.ts+++ b/editor/src/panels/hierarchy/HierarchyContextMenu.ts@@ -11,6 +11,7 @@ import { joinPath, getParentDir } from '../../utils/path';import { hasAnyOverrides } from '../../prefab';import { getAssetTypeDescriptor } from '../../asset/AssetTypeRegistry';import type { HierarchyState } from './HierarchyTypes';+import { instantiateTemplate } from './EntityTemplates';export function showEntityContextMenu(state: HierarchyState, x: number, y: number, entity: Entity | null): void {const entityData = entity !== null ? state.store.getEntityData(entity as number) : null;@@ -31,21 +32,21 @@ export function showEntityContextMenu(state: HierarchyState, x: number, y: numbe{ label: 'Spine', icon: icons.bone(14), onClick: () => createEntityWithComponent(state, 'SpineAnimation', entity) },{ label: 'Shape', icon: icons.hexagon(14), onClick: () => createEntityWithComponent(state, 'ShapeRenderer', entity) },{ label: 'Particle', icon: icons.star(14), onClick: () => createEntityWithComponent(state, 'ParticleEmitter', entity) },- { label: 'Tilemap', icon: icons.grid(14), onClick: () => createTilemapEntity(state, entity) },+ { label: 'Tilemap', icon: icons.grid(14), onClick: () => instantiateTemplate(state, 'Tilemap', entity) },] },{ label: 'UI', icon: icons.pointer(14), children: [{ label: 'Canvas', icon: icons.template(14), onClick: () => createEntityWithComponent(state, 'Canvas', entity) },{ label: '', separator: true },- { label: 'Button', icon: icons.pointer(14), onClick: () => createButtonEntity(state, entity) },+ { label: 'Button', icon: icons.pointer(14), onClick: () => instantiateTemplate(state, 'Button', entity) },{ label: 'TextInput', icon: icons.type(14), onClick: () => createTextInputEntity(state, entity) },- { label: 'Image', icon: icons.image(14), onClick: () => createImageEntity(state, entity) },- { label: 'Panel', icon: icons.layers(14), onClick: () => createPanelEntity(state, entity) },+ { label: 'Image', icon: icons.image(14), onClick: () => instantiateTemplate(state, 'Image', entity) },+ { label: 'Panel', icon: icons.layers(14), onClick: () => instantiateTemplate(state, 'Panel', entity) },{ label: '', separator: true },- { label: 'Toggle', icon: icons.toggle(14), onClick: () => createToggleEntity(state, entity) },- { label: 'Slider', icon: icons.sliders(14), onClick: () => createSliderEntity(state, entity) },- { label: 'ProgressBar', icon: icons.gauge(14), onClick: () => createProgressBarEntity(state, entity) },- { label: 'ScrollView', icon: icons.list(14), onClick: () => createScrollViewEntity(state, entity) },- { label: 'Dropdown', icon: icons.chevronDown(14), onClick: () => createDropdownEntity(state, entity) },+ { label: 'Toggle', icon: icons.toggle(14), onClick: () => instantiateTemplate(state, 'Toggle', entity) },+ { label: 'Slider', icon: icons.sliders(14), onClick: () => instantiateTemplate(state, 'Slider', entity) },+ { label: 'ProgressBar', icon: icons.gauge(14), onClick: () => instantiateTemplate(state, 'ProgressBar', entity) },+ { label: 'ScrollView', icon: icons.list(14), onClick: () => instantiateTemplate(state, 'ScrollView', entity) },+ { label: 'Dropdown', icon: icons.chevronDown(14), onClick: () => instantiateTemplate(state, 'Dropdown', entity) },] },{ label: 'Audio', icon: icons.volume(14), children: [{ label: 'AudioSource', icon: icons.volume(14), onClick: () => createAudioEntity(state, 'AudioSource', entity) },@@ -233,15 +234,6 @@ function createPhysicsEntity(state: HierarchyState, colliderType: string, parentstate.store.addComponent(newEntity, colliderType, getInitialComponentData(colliderType));}-function createButtonEntity(state: HierarchyState, parent: Entity | null): void {- const newEntity = state.store.createEntity('Button', parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, 'Image', getInitialComponentData('Image'));- state.store.addComponent(newEntity, 'UIRect', getInitialComponentData('UIRect'));- state.store.addComponent(newEntity, 'Interactable', getInitialComponentData('Interactable'));- state.store.addComponent(newEntity, 'Button', getInitialComponentData('Button'));-}-function createTextInputEntity(state: HierarchyState, parent: Entity | null): void {const newEntity = state.store.createEntity('TextInput', parent);state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));@@ -258,207 +250,6 @@ function createTextInputEntity(state: HierarchyState, parent: Entity | null): vostate.store.addComponent(newEntity, 'TextInput', getInitialComponentData('TextInput'));}-function createPanelEntity(state: HierarchyState, parent: Entity | null): void {- const newEntity = state.store.createEntity('Panel', parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, 'Image', getInitialComponentData('Image'));- state.store.addComponent(newEntity, 'UIRect', getInitialComponentData('UIRect'));- state.store.addComponent(newEntity, 'UIMask', getInitialComponentData('UIMask'));-}--function createImageEntity(state: HierarchyState, parent: Entity | null): void {- const newEntity = state.store.createEntity('Image', parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, 'Image', getInitialComponentData('Image'));- state.store.addComponent(newEntity, 'UIRect', getInitialComponentData('UIRect'));-}--function createToggleEntity(state: HierarchyState, parent: Entity | null): void {- const toggleEntity = state.store.createEntity('Toggle', parent);- state.store.addComponent(toggleEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(toggleEntity, 'Image', getInitialComponentData('Image'));- state.store.addComponent(toggleEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 24, y: 24 },- });- state.store.addComponent(toggleEntity, 'Interactable', getInitialComponentData('Interactable'));-- const checkmark = state.store.createEntity('Checkmark', toggleEntity);- state.store.addComponent(checkmark, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(checkmark, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.2, g: 0.2, b: 0.2, a: 1 },- });- state.store.addComponent(checkmark, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 16, y: 16 },- });-- state.store.addComponent(toggleEntity, 'Toggle', {- ...getInitialComponentData('Toggle'),- graphicEntity: checkmark as number,- });-- state.store.selectEntity(toggleEntity);-}--function createProgressBarEntity(state: HierarchyState, parent: Entity | null): void {- const barEntity = state.store.createEntity('ProgressBar', parent);- state.store.addComponent(barEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(barEntity, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.3, g: 0.3, b: 0.3, a: 1 },- });- state.store.addComponent(barEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 200, y: 20 },- });-- const fill = state.store.createEntity('Fill', barEntity);- state.store.addComponent(fill, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(fill, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.2, g: 0.6, b: 1, a: 1 },- });- state.store.addComponent(fill, 'UIRect', {- ...getInitialComponentData('UIRect'),- anchorMin: { x: 0, y: 0 },- anchorMax: { x: 0.5, y: 1 },- offsetMin: { x: 0, y: 0 },- offsetMax: { x: 0, y: 0 },- });-- state.store.addComponent(barEntity, 'ProgressBar', {- ...getInitialComponentData('ProgressBar'),- value: 0.5,- fillEntity: fill as number,- });-- state.store.selectEntity(barEntity);-}--function createScrollViewEntity(state: HierarchyState, parent: Entity | null): void {- const scrollEntity = state.store.createEntity('ScrollView', parent);- state.store.addComponent(scrollEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(scrollEntity, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.15, g: 0.15, b: 0.15, a: 1 },- });- state.store.addComponent(scrollEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 300, y: 200 },- });- state.store.addComponent(scrollEntity, 'UIMask', getInitialComponentData('UIMask'));- state.store.addComponent(scrollEntity, 'Interactable', getInitialComponentData('Interactable'));-- const content = state.store.createEntity('Content', scrollEntity);- state.store.addComponent(content, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(content, 'UIRect', {- ...getInitialComponentData('UIRect'),- anchorMin: { x: 0, y: 0 },- anchorMax: { x: 1, y: 1 },- offsetMin: { x: 0, y: 0 },- offsetMax: { x: 0, y: 0 },- });-- state.store.addComponent(scrollEntity, 'ScrollView', {- ...getInitialComponentData('ScrollView'),- contentEntity: content as number,- });-- state.store.selectEntity(scrollEntity);-}--function createSliderEntity(state: HierarchyState, parent: Entity | null): void {- const sliderEntity = state.store.createEntity('Slider', parent);- state.store.addComponent(sliderEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(sliderEntity, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.3, g: 0.3, b: 0.3, a: 1 },- });- state.store.addComponent(sliderEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 200, y: 20 },- });- state.store.addComponent(sliderEntity, 'Interactable', getInitialComponentData('Interactable'));-- const fill = state.store.createEntity('Fill', sliderEntity);- state.store.addComponent(fill, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(fill, 'Image', {- ...getInitialComponentData('Image'),- color: { r: 0.2, g: 0.6, b: 1, a: 1 },- });- state.store.addComponent(fill, 'UIRect', {- ...getInitialComponentData('UIRect'),- anchorMin: { x: 0, y: 0 },- anchorMax: { x: 0.5, y: 1 },- offsetMin: { x: 0, y: 0 },- offsetMax: { x: 0, y: 0 },- });-- const handle = state.store.createEntity('Handle', sliderEntity);- state.store.addComponent(handle, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(handle, 'Image', getInitialComponentData('Image'));- state.store.addComponent(handle, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 20, y: 20 },- });-- state.store.addComponent(sliderEntity, 'Slider', {- ...getInitialComponentData('Slider'),- value: 0.5,- fillEntity: fill as number,- handleEntity: handle as number,- });-- state.store.selectEntity(sliderEntity);-}--function createDropdownEntity(state: HierarchyState, parent: Entity | null): void {- const ddEntity = state.store.createEntity('Dropdown', parent);- state.store.addComponent(ddEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(ddEntity, 'Image', getInitialComponentData('Image'));- state.store.addComponent(ddEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 160, y: 32 },- });- state.store.addComponent(ddEntity, 'Interactable', getInitialComponentData('Interactable'));-- const label = state.store.createEntity('Label', ddEntity);- state.store.addComponent(label, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(label, 'UIRect', {- ...getInitialComponentData('UIRect'),- anchorMin: { x: 0, y: 0 },- anchorMax: { x: 1, y: 1 },- offsetMin: { x: 8, y: 0 },- offsetMax: { x: -8, y: 0 },- });- state.store.addComponent(label, 'Text', {- ...getInitialComponentData('Text'),- content: 'Select...',- });-- const list = state.store.createEntity('List', ddEntity);- state.store.addComponent(list, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(list, 'Image', {- ...getInitialComponentData('Image'),- enabled: false,- });- state.store.addComponent(list, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 160, y: 120 },- });-- state.store.addComponent(ddEntity, 'Dropdown', {- ...getInitialComponentData('Dropdown'),- options: ['Option 1', 'Option 2', 'Option 3'],- labelEntity: label as number,- listEntity: list as number,- });-- state.store.selectEntity(ddEntity);-}-export function duplicateEntity(state: HierarchyState, entity: Entity): void {const entityData = state.store.getEntityData(entity as number);if (!entityData) return;@@ -534,12 +325,6 @@ async function saveEntityAsPrefab(state: HierarchyState, entity: Entity): Promis}}-function createTilemapEntity(state: HierarchyState, parent: Entity | null): void {- const newEntity = state.store.createEntity('Tilemap', parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, 'Tilemap', getInitialComponentData('Tilemap'));-}-export async function createEntityFromAsset(state: HierarchyState,asset: { type: string; path: string; name: string },diff --git a/editor/src/panels/hierarchy/HierarchyPanel.ts b/editor/src/panels/hierarchy/HierarchyPanel.tsindex 11d000791..eb5ebcd2d 100644--- a/editor/src/panels/hierarchy/HierarchyPanel.ts+++ b/editor/src/panels/hierarchy/HierarchyPanel.ts@@ -6,7 +6,7 @@ import { escapeHtml } from '../../utils/html';import { getInitialComponentData } from '../../schemas/ComponentSchemas';import type { HierarchyState, FlattenedRow } from './HierarchyTypes';import { ROW_HEIGHT, OVERSCAN, SLOW_DOUBLE_CLICK_MIN, SLOW_DOUBLE_CLICK_MAX } from './HierarchyTypes';-import { buildFlatRows, expandAncestors, renderSingleRow } from './HierarchyTree';+import { buildFlatRows, expandAncestors, renderSingleRow, getEntityTypeCategory } from './HierarchyTree';import { performSearch, selectNextResult, selectPreviousResult, focusSelectedResult, clearSearch } from './HierarchySearch';import { setupKeyboard, selectRange } from './HierarchyKeyboard';import { setupDragAndDrop } from './HierarchyDragDrop';@@ -56,15 +56,14 @@ export class HierarchyPanel implements HierarchyState {<span class="es-prefab-edit-name">${icons.package(12)} </span></div><div class="es-hierarchy-toolbar">- <input type="text" class="es-input es-hierarchy-search" placeholder="Search...">- <button class="es-btn es-btn-icon" data-action="collapse-all" title="Collapse All">${icons.chevronRight(12)}</button>- <button class="es-btn es-btn-icon" data-action="expand-all" title="Expand All">${icons.chevronDown(12)}</button>- <button class="es-btn es-btn-icon" data-action="add" title="Create Entity">${icons.plus()}</button>- <button class="es-btn es-btn-icon" data-action="duplicate" title="Duplicate">${icons.copy()}</button>+ <input type="text" class="es-input es-hierarchy-search" placeholder="Search (t:type)">+ <button class="es-btn es-btn-icon" data-action="collapse-all" data-tooltip="Collapse All">${icons.chevronRight(12)}</button>+ <button class="es-btn es-btn-icon" data-action="expand-all" data-tooltip="Expand All">${icons.chevronDown(12)}</button>+ <button class="es-btn es-btn-icon" data-action="add" data-tooltip="Create Entity">${icons.plus()}</button>+ <button class="es-btn es-btn-icon" data-action="duplicate" data-tooltip="Duplicate">${icons.copy()}</button></div><div class="es-hierarchy-columns"><span class="es-hierarchy-col-visibility">${icons.eye(12)}</span>- <span class="es-hierarchy-col-lock">${icons.star(12)}</span><span class="es-hierarchy-col-label">Item Label</span><span class="es-hierarchy-col-type">Type</span></div>@@ -523,10 +522,31 @@ export class HierarchyPanel implements HierarchyState {if (this.searchFilter) {const count = this.searchResults.length;this.footerContainer_.textContent = `${count} ${count === 1 ? 'match' : 'matches'}`;- } else {- const count = this.store.scene.entities.length;- this.footerContainer_.textContent = `${count} ${count === 1 ? 'entity' : 'entities'}`;+ return;+ }++ const entities = this.store.scene.entities;+ const count = entities.length;+ const selectedCount = this.store.selectedEntities.size;++ if (selectedCount > 1) {+ this.footerContainer_.textContent = `${count} entities · ${selectedCount} selected`;+ return;+ }++ const typeCounts = new Map<string, number>();+ for (const entity of entities) {+ const cat = getEntityTypeCategory(entity);+ if (cat !== 'default') {+ typeCounts.set(cat, (typeCounts.get(cat) ?? 0) + 1);+ }+ }++ let text = `${count} ${count === 1 ? 'entity' : 'entities'}`;+ for (const [cat, n] of typeCounts) {+ text += ` · ${n} ${cat.charAt(0).toUpperCase() + cat.slice(1)}`;}+ this.footerContainer_.textContent = text;}renderVisibleRows(): void {diff --git a/editor/src/panels/hierarchy/HierarchySearch.ts b/editor/src/panels/hierarchy/HierarchySearch.tsindex fda7d3449..42488af28 100644--- a/editor/src/panels/hierarchy/HierarchySearch.ts+++ b/editor/src/panels/hierarchy/HierarchySearch.ts@@ -1,6 +1,29 @@import type { Entity } from 'esengine';import { fuzzyFilter } from '../../utils/fuzzy';import type { HierarchyState } from './HierarchyTypes';+import { getEntityTypeCategory } from './HierarchyTree';++const TYPE_ALIASES: Record<string, string> = {+ ui: 'ui',+ physics: 'physics',+ phy: 'physics',+ audio: 'audio',+ sfx: 'audio',+ particle: 'particle',+ spine: 'spine',+ camera: 'default',+ cam: 'default',+};++function parseSearchQuery(query: string): { typeFilter: string | null; nameQuery: string } {+ const match = query.match(/^t:(\w+)(?:\s+(.*))?$/);+ if (match) {+ const alias = match[1].toLowerCase();+ const category = TYPE_ALIASES[alias] ?? alias;+ return { typeFilter: category, nameQuery: match[2]?.trim() ?? '' };+ }+ return { typeFilter: null, nameQuery: query };+}export function performSearch(state: HierarchyState): void {if (!state.searchFilter) {@@ -10,13 +33,26 @@ export function performSearch(state: HierarchyState): void {}const entities = state.runtimeEntities ?? state.store.scene.entities;- const results = fuzzyFilter(- entities,- state.searchFilter,- (entity) => entity.name- );+ const { typeFilter, nameQuery } = parseSearchQuery(state.searchFilter);++ let filtered = entities;+ if (typeFilter) {+ filtered = entities.filter(e => {+ const cat = getEntityTypeCategory(e);+ if (typeFilter === 'default') {+ return e.components.some(c => c.type === 'Camera');+ }+ return cat === typeFilter;+ });+ }++ if (!nameQuery) {+ state.searchResults = filtered.map(e => ({ entity: e, match: { score: 0, matches: [] } }));+ } else {+ const results = fuzzyFilter(filtered, nameQuery, (entity) => entity.name);+ state.searchResults = results.map(r => ({ entity: r.item, match: r.match }));+ }- state.searchResults = results.map(r => ({ entity: r.item, match: r.match }));state.selectedResultIndex = state.searchResults.length > 0 ? 0 : -1;}diff --git a/editor/src/panels/hierarchy/HierarchyTree.ts b/editor/src/panels/hierarchy/HierarchyTree.tsindex 2d028df20..662aecaeb 100644--- a/editor/src/panels/hierarchy/HierarchyTree.ts+++ b/editor/src/panels/hierarchy/HierarchyTree.ts@@ -74,6 +74,20 @@ const ENTITY_ICON_PRIORITY: Array<[string, (size: number) => string]> = [['BitmapText', icons.type],['TextInput', icons.type],['Sprite', icons.image],+ ['Image', icons.image],+ ['Canvas', icons.template],+ ['Button', icons.pointer],+ ['Toggle', icons.toggle],+ ['Slider', icons.sliders],+ ['ScrollView', icons.list],+ ['ProgressBar', icons.gauge],+ ['Dropdown', icons.chevronDown],+ ['ParticleEmitter', icons.star],+ ['ShapeRenderer', icons.hexagon],+ ['Tilemap', icons.grid],+ ['AudioSource', icons.volume],+ ['AudioListener', icons.headphones],+ ['RigidBody', icons.box],];export function getEntityIcon(entity: EntityData): string {@@ -93,22 +107,53 @@ export function getEntityIcon(entity: EntityData): string {: icons.box(12);}-const ENTITY_TYPE_PRIORITY: Array<[string, string]> = [- ['Camera', 'Camera'],- ['SpineAnimation', 'Spine'],+const ENTITY_TYPE_MAP: Array<[string, string, string]> = [+ ['Camera', 'Camera', 'default'],+ ['SpineAnimation', 'Spine', 'spine'],+ ['Canvas', 'Canvas', 'ui'],+ ['Text', 'Text', 'ui'],+ ['BitmapText', 'Text', 'ui'],+ ['TextInput', 'Text', 'ui'],+ ['Button', 'UI', 'ui'],+ ['Toggle', 'UI', 'ui'],+ ['Slider', 'UI', 'ui'],+ ['ScrollView', 'UI', 'ui'],+ ['ProgressBar', 'UI', 'ui'],+ ['Dropdown', 'UI', 'ui'],+ ['Image', 'UI', 'ui'],+ ['Sprite', 'Sprite', 'default'],+ ['RigidBody', 'Physics', 'physics'],+ ['BoxCollider', 'Physics', 'physics'],+ ['CircleCollider', 'Physics', 'physics'],+ ['CapsuleCollider', 'Physics', 'physics'],+ ['PolygonCollider', 'Physics', 'physics'],+ ['AudioSource', 'Audio', 'audio'],+ ['AudioListener', 'Audio', 'audio'],+ ['ParticleEmitter', 'Particle', 'particle'],+ ['ShapeRenderer', 'Shape', 'default'],+ ['Tilemap', 'Tilemap', 'default'],];-export function getEntityType(entity: EntityData): string {- for (const [compType, label] of ENTITY_TYPE_PRIORITY) {- if (entity.components.some(c => c.type === compType)) return label;+export interface EntityTypeInfo {+ label: string;+ category: string;+}++export function getEntityType(entity: EntityData): EntityTypeInfo {+ for (const [compType, label, category] of ENTITY_TYPE_MAP) {+ if (entity.components.some(c => c.type === compType)) return { label, category };}- return 'Entity';+ return { label: 'Entity', category: 'default' };+}++export function getEntityTypeCategory(entity: EntityData): string {+ return getEntityType(entity).category;}export function renderSingleRow(state: HierarchyState, row: FlattenedRow, selectedEntity: Entity | null): string {const { entity, depth, hasChildren, isExpanded } = row;const icon = getEntityIcon(entity);- const type = getEntityType(entity);+ const { label: type, category } = getEntityType(entity);const expandIcon = isExpanded ? icons.chevronDown(10) : icons.chevronRight(10);const inPlayMode = state.playMode;@@ -149,7 +194,7 @@ export function renderSingleRow(state: HierarchyState, row: FlattenedRow, select<span class="es-hierarchy-visibility">${visibilityIcon}</span><span class="es-hierarchy-icon">${icon}</span><span class="es-hierarchy-name">${nameHtml}</span>- <span class="es-hierarchy-type">${type}</span>+ <span class="es-hierarchy-type" data-type-cat="${category}">${type}</span></div></div>`;}diff --git a/editor/src/property/editors/colorEditor.ts b/editor/src/property/editors/colorEditor.tsindex c680689dc..f6d6ddb0f 100644--- a/editor/src/property/editors/colorEditor.ts+++ b/editor/src/property/editors/colorEditor.ts@@ -23,11 +23,20 @@ export function createColorEditor(const wrapper = document.createElement('div');wrapper.className = 'es-color-editor';+ const swatch = document.createElement('div');+ swatch.className = 'es-color-swatch';++ const overlay = document.createElement('div');+ overlay.className = 'es-color-overlay';+const colorInput = document.createElement('input');colorInput.type = 'color';colorInput.className = 'es-input es-input-color';colorInput.value = colorToHex(color);+ swatch.appendChild(overlay);+ swatch.appendChild(colorInput);+const hexInput = document.createElement('input');hexInput.type = 'text';hexInput.className = 'es-input es-input-hex';@@ -41,9 +50,16 @@ export function createColorEditor(alphaInput.step = '0.01';alphaInput.value = String(color.a);+ const updateOverlay = (hex: string, alpha: number) => {+ const c = hexToColor(hex);+ overlay.style.background = `rgba(${Math.round(c.r * 255)}, ${Math.round(c.g * 255)}, ${Math.round(c.b * 255)}, ${alpha})`;+ };+ updateOverlay(colorToHex(color), color.a);+const applyColor = (hex: string, alpha: number) => {const newColor = hexToColor(hex);newColor.a = alpha;+ updateOverlay(hex, alpha);onChange(newColor);};@@ -69,7 +85,7 @@ export function createColorEditor(}});- wrapper.appendChild(colorInput);+ wrapper.appendChild(swatch);wrapper.appendChild(hexInput);wrapper.appendChild(alphaInput);container.appendChild(wrapper);@@ -80,6 +96,7 @@ export function createColorEditor(colorInput.value = colorToHex(newColor);hexInput.value = colorToHex(newColor).toUpperCase();alphaInput.value = String(newColor.a);+ updateOverlay(colorToHex(newColor), newColor.a);},dispose() {wrapper.remove();diff --git a/editor/src/property/editors/entityEditor.ts b/editor/src/property/editors/entityEditor.tsindex 65242a0ec..8ebda54e6 100644--- a/editor/src/property/editors/entityEditor.ts+++ b/editor/src/property/editors/entityEditor.ts@@ -4,6 +4,7 @@ import {} from '../PropertyEditor';import { getEditorStore } from '../../store/EditorStore';import { openEntityPicker } from '../EntityPicker';+import { getEntityIcon } from '../../panels/hierarchy/HierarchyTree';export function createEntityEditor(container: HTMLElement,@@ -16,6 +17,9 @@ export function createEntityEditor(const wrapper = document.createElement('div');wrapper.className = 'es-entity-field';+ const iconSpan = document.createElement('span');+ iconSpan.className = 'es-entity-field-icon';+const label = document.createElement('span');label.className = 'es-entity-field-label';updateLabel(currentValue);@@ -71,6 +75,7 @@ export function createEntityEditor(}});+ wrapper.appendChild(iconSpan);wrapper.appendChild(label);wrapper.appendChild(pickerBtn);container.appendChild(wrapper);@@ -79,10 +84,19 @@ export function createEntityEditor(if (entityId === 0) {label.textContent = '(None)';label.classList.add('es-none');+ iconSpan.innerHTML = '';+ iconSpan.style.display = 'none';} else {label.classList.remove('es-none');const entity = getEditorStore().scene.entities.find((e: { id: number }) => e.id === entityId);label.textContent = entity ? entity.name : `Entity ${entityId}`;+ if (entity) {+ iconSpan.innerHTML = getEntityIcon(entity);+ iconSpan.style.display = '';+ } else {+ iconSpan.innerHTML = '';+ iconSpan.style.display = 'none';+ }}}diff --git a/editor/src/property/editors/numberEditor.ts b/editor/src/property/editors/numberEditor.tsindex 2b9d02855..253ff42a5 100644--- a/editor/src/property/editors/numberEditor.ts+++ b/editor/src/property/editors/numberEditor.ts@@ -5,6 +5,57 @@ import {import { setupDragLabel } from '../editorUtils';import { validateNumber, showValidationError } from '../validation';+function setupSlider(+ slider: HTMLElement,+ input: HTMLInputElement,+ min: number,+ max: number,+ step: number,+ onChange: (value: number) => void,+): void {+ const updateFill = () => {+ const val = parseFloat(input.value) || 0;+ const pct = Math.max(0, Math.min(100, ((val - min) / (max - min)) * 100));+ slider.style.setProperty('--slider-pct', `${pct}%`);+ };+ updateFill();++ const inputObserver = new MutationObserver(updateFill);+ inputObserver.observe(input, { attributes: true, attributeFilter: ['value'] });++ const origSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!;+ const patched = function (this: HTMLInputElement, v: string) {+ origSet.call(this, v);+ updateFill();+ };+ Object.defineProperty(input, 'value', { set: patched, get: Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.get });++ const applyFromEvent = (e: MouseEvent) => {+ const rect = slider.getBoundingClientRect();+ const pct = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));+ let val = min + pct * (max - min);+ val = Math.round(val / step) * step;+ val = parseFloat(val.toFixed(4));+ input.value = String(val);+ updateFill();+ onChange(val);+ };++ slider.addEventListener('mousedown', (e) => {+ e.preventDefault();+ applyFromEvent(e);+ const onMove = (ev: MouseEvent) => applyFromEvent(ev);+ const onUp = () => {+ document.removeEventListener('mousemove', onMove);+ document.removeEventListener('mouseup', onUp);+ document.body.style.cursor = '';+ };+ document.body.style.cursor = 'ew-resize';+ document.addEventListener('mousemove', onMove);+ document.addEventListener('mouseup', onUp);+ });+}+export function createNumberEditor(container: HTMLElement,ctx: PropertyEditorContext@@ -17,7 +68,7 @@ export function createNumberEditor(const label = document.createElement('span');label.className = 'es-number-drag-label';label.innerHTML = '⋮⋮';- label.title = 'Drag to adjust value';+ label.dataset.tooltip = 'Drag to adjust value';const input = document.createElement('input');input.type = 'number';@@ -29,6 +80,7 @@ export function createNumberEditor(if (meta.step !== undefined) input.step = String(meta.step);const step = meta.step ?? 1;+ const hasRange = meta.min !== undefined && meta.max !== undefined;const handleChange = () => {const result = validateNumber(input.value, meta);@@ -50,10 +102,18 @@ export function createNumberEditor(setupDragLabel(label, input, (newValue) => {onChange(newValue);- }, step);+ }, step, meta.min, meta.max);wrapper.appendChild(label);wrapper.appendChild(input);++ if (hasRange) {+ const slider = document.createElement('div');+ slider.className = 'es-number-slider';+ setupSlider(slider, input, meta.min!, meta.max!, step, onChange);+ wrapper.appendChild(slider);+ }+container.appendChild(wrapper);return {diff --git a/editor/src/styles/base.css b/editor/src/styles/base.cssindex 9f7145734..3ebdef78b 100644--- a/editor/src/styles/base.css+++ b/editor/src/styles/base.css@@ -45,6 +45,13 @@--es-play-mode: hsl(215, 100%, 65%);--es-selection-bg: hsla(28, 55%, 62%, 0.2);+ /* Entity type colors */+ --es-type-ui: hsl(215, 80%, 65%);+ --es-type-physics: hsl(130, 50%, 55%);+ --es-type-audio: hsl(280, 50%, 65%);+ --es-type-particle: hsl(36, 70%, 65%);+ --es-type-spine: hsl(350, 60%, 65%);+/* Scrollbar */--es-scrollbar-track: transparent;--es-scrollbar-thumb: hsl(220, 5%, 22%);@@ -322,6 +329,19 @@color: var(--es-text-secondary);}+.es-number-slider {+ flex: 1;+ min-width: 40px;+ height: var(--es-row-height);+ background: linear-gradient(to right, var(--es-accent) var(--slider-pct, 0%), var(--es-bg-tertiary) var(--slider-pct, 0%));+ cursor: ew-resize;+ border-left: 1px solid var(--es-border);+}++.es-number-slider:hover {+ background: linear-gradient(to right, var(--es-accent-hover) var(--slider-pct, 0%), var(--es-bg-hover) var(--slider-pct, 0%));+}+.es-input-checkbox {width: 14px;height: 14px;@@ -330,6 +350,112 @@accent-color: var(--es-accent-gold);}+/* =============================================================================+ * Toggle Switch+ * ============================================================================= */++.es-toggle {+ display: inline-flex;+ align-items: center;+ cursor: pointer;+}++.es-toggle-input {+ position: absolute;+ opacity: 0;+ width: 0;+ height: 0;+}++.es-toggle-track {+ position: relative;+ width: 28px;+ height: 16px;+ background: var(--es-bg-tertiary);+ border: 1px solid var(--es-border);+ border-radius: var(--es-radius-full);+ transition: background var(--es-transition-normal), border-color var(--es-transition-normal);+}++.es-toggle-track::after {+ content: '';+ position: absolute;+ top: 2px;+ left: 2px;+ width: 10px;+ height: 10px;+ background: var(--es-text-secondary);+ border-radius: 50%;+ transition: transform var(--es-transition-normal), background var(--es-transition-normal);+}++.es-toggle-input:checked + .es-toggle-track {+ background: var(--es-accent);+ border-color: var(--es-accent);+}++.es-toggle-input:checked + .es-toggle-track::after {+ transform: translateX(12px);+ background: var(--es-text-bright);+}++.es-toggle:hover .es-toggle-track {+ border-color: var(--es-border-light);+}++.es-toggle-input:focus-visible + .es-toggle-track {+ outline: 2px solid var(--es-border-focus);+ outline-offset: 2px;+}++/* =============================================================================+ * Segmented Control (Enum ≤ 5 options)+ * ============================================================================= */++.es-segmented {+ display: flex;+ background: var(--es-input-bg);+ border: 1px solid var(--es-border);+ border-radius: var(--es-radius-sm);+ overflow: hidden;+ width: 100%;+}++.es-segmented-btn {+ flex: 1;+ padding: 2px 4px;+ background: transparent;+ border: none;+ border-right: 1px solid var(--es-border);+ color: var(--es-text-secondary);+ font-size: var(--es-font-xs);+ cursor: pointer;+ transition: background var(--es-transition-fast), color var(--es-transition-fast);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ min-height: 22px;+}++.es-segmented-btn:last-child {+ border-right: none;+}++.es-segmented-btn:hover:not(.es-active) {+ background: var(--es-bg-hover);+ color: var(--es-text-primary);+}++.es-segmented-btn.es-active {+ background: var(--es-accent);+ color: var(--es-text-bright);+}++.es-segmented-btn:focus-visible {+ outline: 2px solid var(--es-border-focus);+ outline-offset: -2px;+}+.es-input-select {width: 100%;cursor: pointer;@@ -462,17 +588,37 @@width: 100%;}-.es-input-color {- width: 32px;+.es-color-swatch {+ position: relative;+ width: 40px;height: 22px;- padding: 0;+ flex-shrink: 0;border: 1px solid var(--es-border);+ border-radius: 3px;+ overflow: hidden;+ background: repeating-conic-gradient(hsl(220, 5%, 18%) 0% 25%, hsl(220, 5%, 28%) 0% 50%) 50% / 8px 8px;+ cursor: pointer;+}++.es-color-overlay {+ position: absolute;+ inset: 0;+ pointer-events: none;+}++.es-input-color {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ padding: 0;+ border: none;cursor: pointer;- background: none;+ opacity: 0;}.es-input-color::-webkit-color-swatch-wrapper {- padding: 1px;+ padding: 0;}.es-input-color::-webkit-color-swatch {@@ -633,6 +779,44 @@margin-top: 16px;}+/* =============================================================================+ * Tooltip System+ * ============================================================================= */++[data-tooltip] {+ position: relative;+}++[data-tooltip]::after {+ content: attr(data-tooltip);+ position: absolute;+ bottom: calc(100% + 6px);+ left: 50%;+ transform: translateX(-50%);+ padding: 4px 8px;+ background: var(--es-bg-deep);+ color: var(--es-text-primary);+ font-size: var(--es-font-xs);+ line-height: 1.4;+ white-space: nowrap;+ border-radius: var(--es-radius-sm);+ border: 1px solid var(--es-border);+ box-shadow: var(--es-shadow-md);+ pointer-events: none;+ opacity: 0;+ transition: opacity var(--es-transition-normal);+ z-index: 9999;+}++[data-tooltip]:hover::after {+ opacity: 1;+ transition-delay: 0.4s;+}++[data-tooltip=""]:hover::after {+ display: none;+}+.es-hidden {display: none !important;}diff --git a/editor/src/styles/hierarchy.css b/editor/src/styles/hierarchy.cssindex b08655534..3c7e0b15c 100644--- a/editor/src/styles/hierarchy.css+++ b/editor/src/styles/hierarchy.css@@ -33,8 +33,7 @@color: var(--es-text-secondary);}-.es-hierarchy-col-visibility,-.es-hierarchy-col-lock {+.es-hierarchy-col-visibility {width: 20px;text-align: center;}@@ -205,6 +204,12 @@color: var(--es-text-secondary);}+.es-hierarchy-type[data-type-cat="ui"] { color: var(--es-type-ui); }+.es-hierarchy-type[data-type-cat="physics"] { color: var(--es-type-physics); }+.es-hierarchy-type[data-type-cat="audio"] { color: var(--es-type-audio); }+.es-hierarchy-type[data-type-cat="particle"] { color: var(--es-type-particle); }+.es-hierarchy-type[data-type-cat="spine"] { color: var(--es-type-spine); }+.es-hierarchy-rename-input {width: 100%;height: 18px;diff --git a/editor/src/styles/inspector.css b/editor/src/styles/inspector.cssindex 46f452478..ef281d9fd 100644--- a/editor/src/styles/inspector.css+++ b/editor/src/styles/inspector.css@@ -274,6 +274,14 @@white-space: nowrap;}+.es-component-description {+ padding: 4px 8px 6px;+ font-size: 10px;+ color: var(--es-text-muted);+ line-height: 1.4;+ border-bottom: 1px solid var(--es-border);+}+.es-component-enabled-toggle {flex-shrink: 0;width: 13px;@@ -405,6 +413,11 @@align-items: center;}+.es-property-readonly {+ opacity: 0.6;+ pointer-events: none;+}+.es-btn-reset-size {flex-shrink: 0;margin-left: 4px;@@ -761,6 +774,22 @@padding: 0 1px;}+.es-component-item.es-disabled {+ opacity: 0.4;+ cursor: not-allowed;+ pointer-events: none;+}++.es-component-desc {+ font-size: 11px;+ color: var(--es-text-secondary);+ margin-left: auto;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ max-width: 180px;+}+.es-component-name {font-size: 13px;color: var(--es-text-primary);@@ -941,8 +970,8 @@}.es-texture-preview {- width: 64px;- height: 64px;+ width: 80px;+ height: 80px;background: repeating-conic-gradient(hsl(220, 5%, 18%) 0% 25%, hsl(220, 5%, 24%) 0% 50%) 50% / 8px 8px;border: 1px solid var(--es-border);border-radius: 4px;@@ -1343,6 +1372,19 @@overflow: hidden;}+.es-entity-field-icon {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 18px;+ flex-shrink: 0;+ margin-left: 4px;+}++.es-entity-field-icon svg {+ stroke: var(--es-text-secondary);+}+.es-entity-field-label {flex: 1;min-width: 0;