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
refactor: extract UI entity utilities and improve hierarchy templates
esengineb8984ab7a0a4
diff --git a/editor/src/gizmos/TilemapOverlay.ts b/editor/src/gizmos/TilemapOverlay.tsindex ff8034be4..b2f5b1354 100644--- a/editor/src/gizmos/TilemapOverlay.ts+++ b/editor/src/gizmos/TilemapOverlay.ts@@ -61,10 +61,6 @@ export class TilemapOverlay {ctx.save();- for (const layer of cached.layers) {- this.drawLayer_(ctx, cached, layer, ox, oy);- }-if (cached.layers.length > 0) {const firstLayer = cached.layers[0];this.drawGrid_(ctx, firstLayer.width, firstLayer.height,diff --git a/editor/src/gizmos/builtinGizmos.ts b/editor/src/gizmos/builtinGizmos.tsindex 0950ca7e1..19f7c3559 100644--- a/editor/src/gizmos/builtinGizmos.ts+++ b/editor/src/gizmos/builtinGizmos.ts@@ -203,25 +203,42 @@ export function createMoveGizmo(): GizmoDescriptor {const entity = gctx.store.selectedEntity;if (entity === null || !dragState) return;- const dx = worldX - dragState.startWorldX;- const dy = worldY - dragState.startWorldY;+ let dx = worldX - dragState.startWorldX;+ let dy = worldY - dragState.startWorldY;- let newX = dragState.startValue.x;- let newY = dragState.startValue.y;-- if (dragAxis === 'x' || dragAxis === 'xy') newX += dx;- if (dragAxis === 'y' || dragAxis === 'xy') newY += dy;+ if (dragAxis === 'x') dy = 0;+ if (dragAxis === 'y') dx = 0;const snapActive = event && (event.ctrlKey || event.metaKey);- if (snapActive) {- const gridSize = getSettingsValue<number>('scene.gridSize') ?? 50;- newX = Math.round(newX / gridSize) * gridSize;- newY = Math.round(newY / gridSize) * gridSize;- }- gctx.store.updatePropertyDirect(entity, 'Transform', 'position', {- x: newX, y: newY, z: dragState.startValue.z,- });+ if (dragState.originalOffsetMin && dragState.originalOffsetMax) {+ let newMinX = dragState.originalOffsetMin.x + dx;+ let newMinY = dragState.originalOffsetMin.y + dy;+ let newMaxX = dragState.originalOffsetMax.x + dx;+ let newMaxY = dragState.originalOffsetMax.y + dy;+ if (snapActive) {+ const gridSize = getSettingsValue<number>('scene.gridSize') ?? 50;+ const snapDx = Math.round((dragState.originalOffsetMin.x + dx) / gridSize) * gridSize - dragState.originalOffsetMin.x;+ const snapDy = Math.round((dragState.originalOffsetMin.y + dy) / gridSize) * gridSize - dragState.originalOffsetMin.y;+ newMinX = dragState.originalOffsetMin.x + snapDx;+ newMinY = dragState.originalOffsetMin.y + snapDy;+ newMaxX = dragState.originalOffsetMax.x + snapDx;+ newMaxY = dragState.originalOffsetMax.y + snapDy;+ }+ gctx.store.updatePropertyDirect(entity, 'UIRect', 'offsetMin', { x: newMinX, y: newMinY });+ gctx.store.updatePropertyDirect(entity, 'UIRect', 'offsetMax', { x: newMaxX, y: newMaxY });+ } else {+ let newX = dragState.startValue.x + dx;+ let newY = dragState.startValue.y + dy;+ if (snapActive) {+ const gridSize = getSettingsValue<number>('scene.gridSize') ?? 50;+ newX = Math.round(newX / gridSize) * gridSize;+ newY = Math.round(newY / gridSize) * gridSize;+ }+ gctx.store.updatePropertyDirect(entity, 'Transform', 'position', {+ x: newX, y: newY, z: dragState.startValue.z,+ });+ }gctx.requestRender();},@@ -231,21 +248,23 @@ export function createMoveGizmo(): GizmoDescriptor {if (entity === null || !dragState) { dragState = null; return; }const entityData = gctx.store.getSelectedEntityData();- const transform = entityData?.components.find(c => c.type === 'Transform');- if (transform) {- const currentPos = transform.data.position;- if (currentPos && !valuesEqual(dragState.originalValue, currentPos)) {- if (dragState.originalOffsetMin && dragState.originalOffsetMax) {- const uiRect = entityData?.components.find(c => c.type === 'UIRect');- if (uiRect) {- const curMin = uiRect.data.offsetMin as { x: number; y: number };- const curMax = uiRect.data.offsetMax as { x: number; y: number };- gctx.store.updateBatchProperties(entity, [- { componentType: 'UIRect', property: 'offsetMin', oldValue: { ...dragState.originalOffsetMin }, newValue: { ...curMin } },- { componentType: 'UIRect', property: 'offsetMax', oldValue: { ...dragState.originalOffsetMax }, newValue: { ...curMax } },- ], 'Move UIRect');- }- } else {+ if (dragState.originalOffsetMin && dragState.originalOffsetMax) {+ const uiRect = entityData?.components.find(c => c.type === 'UIRect');+ if (uiRect) {+ const curMin = uiRect.data.offsetMin as { x: number; y: number };+ const curMax = uiRect.data.offsetMax as { x: number; y: number };+ if (!valuesEqual(dragState.originalOffsetMin, curMin) || !valuesEqual(dragState.originalOffsetMax, curMax)) {+ gctx.store.updateBatchProperties(entity, [+ { componentType: 'UIRect', property: 'offsetMin', oldValue: { ...dragState.originalOffsetMin }, newValue: { ...curMin } },+ { componentType: 'UIRect', property: 'offsetMax', oldValue: { ...dragState.originalOffsetMax }, newValue: { ...curMax } },+ ], 'Move UIRect');+ }+ }+ } else {+ const transform = entityData?.components.find(c => c.type === 'Transform');+ if (transform) {+ const currentPos = transform.data.position;+ if (currentPos && !valuesEqual(dragState.originalValue, currentPos)) {gctx.store.updateProperty(entity, 'Transform', 'position',{ ...dragState.originalValue }, deepClone(currentPos),diff --git a/editor/src/panels/hierarchy/EntityTemplates.ts b/editor/src/panels/hierarchy/EntityTemplates.tsindex 406d94313..be1776640 100644--- a/editor/src/panels/hierarchy/EntityTemplates.ts+++ b/editor/src/panels/hierarchy/EntityTemplates.ts@@ -1,6 +1,7 @@import type { Entity } from 'esengine';import { getInitialComponentData } from '../../schemas/ComponentSchemas';import type { HierarchyState } from './HierarchyTypes';+import { resolveUIParent } from './uiEntityUtils';interface ComponentEntry {type: string;@@ -14,17 +15,84 @@ interface EntityTemplateNode {children?: EntityTemplateNode[];}+type EntityCategory = 'ui' | 'physics' | 'general';+interface EntityTemplate {root: EntityTemplateNode;bindings?: Record<string, string>;+ category: EntityCategory;+}++function ui(root: EntityTemplateNode, bindings?: Record<string, string>): EntityTemplate {+ return { root, bindings, category: 'ui' };}-function defineTemplate(root: EntityTemplateNode, bindings?: Record<string, string>): EntityTemplate {- return { root, bindings };+function physics(root: EntityTemplateNode): EntityTemplate {+ return { root, category: 'physics' };}+function general(root: EntityTemplateNode): EntityTemplate {+ return { root, category: 'general' };+}++// =============================================================================+// Template Registry+// =============================================================================+export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {- Button: defineTemplate({+ // ---- General ----+ Sprite: general({+ name: 'Sprite',+ components: [{ type: 'Transform' }, { type: 'Sprite' }],+ }),++ BitmapText: general({+ name: 'BitmapText',+ components: [{ type: 'Transform' }, { type: 'BitmapText' }],+ }),++ SpineAnimation: general({+ name: 'Spine',+ components: [{ type: 'Transform' }, { type: 'SpineAnimation' }],+ }),++ ShapeRenderer: general({+ name: 'Shape',+ components: [{ type: 'Transform' }, { type: 'ShapeRenderer' }],+ }),++ ParticleEmitter: general({+ name: 'Particle',+ components: [{ type: 'Transform' }, { type: 'ParticleEmitter' }],+ }),++ Tilemap: general({+ name: 'Tilemap',+ components: [{ type: 'Transform' }, { type: 'Tilemap' }],+ }),++ Camera: general({+ name: 'Camera',+ components: [{ type: 'Transform' }, { type: 'Camera' }],+ }),++ AudioSource: general({+ name: 'AudioSource',+ components: [{ type: 'Transform' }, { type: 'AudioSource' }],+ }),++ AudioListener: general({+ name: 'AudioListener',+ components: [{ type: 'Transform' }, { type: 'AudioListener' }],+ }),++ // ---- UI ----+ Canvas: general({+ name: 'Canvas',+ components: [{ type: 'Transform' }, { type: 'UIRect' }, { type: 'Canvas' }],+ }),++ Button: ui({name: 'Button',components: [{ type: 'Transform' },@@ -35,7 +103,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {],}),- Panel: defineTemplate({+ Panel: ui({name: 'Panel',components: [{ type: 'Transform' },@@ -45,7 +113,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {],}),- Image: defineTemplate({+ Image: ui({name: 'Image',components: [{ type: 'Transform' },@@ -54,7 +122,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {],}),- Toggle: defineTemplate({+ Toggle: ui({name: 'Toggle',components: [{ type: 'Transform' },@@ -77,7 +145,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {'Toggle.graphicEntity': 'checkmark',}),- ProgressBar: defineTemplate({+ ProgressBar: ui({name: 'ProgressBar',components: [{ type: 'Transform' },@@ -99,7 +167,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {'ProgressBar.fillEntity': 'fill',}),- ScrollView: defineTemplate({+ ScrollView: ui({name: 'ScrollView',components: [{ type: 'Transform' },@@ -122,7 +190,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {'ScrollView.contentEntity': 'content',}),- Slider: defineTemplate({+ Slider: ui({name: 'Slider',components: [{ type: 'Transform' },@@ -154,7 +222,7 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {'Slider.handleEntity': 'handle',}),- Dropdown: defineTemplate({+ Dropdown: ui({name: 'Dropdown',components: [{ type: 'Transform' },@@ -186,15 +254,62 @@ export const ENTITY_TEMPLATES: Record<string, EntityTemplate> = {'Dropdown.listEntity': 'list',}),- Tilemap: defineTemplate({- name: 'Tilemap',+ Text: ui({+ name: 'Text',components: [{ type: 'Transform' },- { type: 'Tilemap' },+ { type: 'UIRect' },+ { type: 'Text' },],}),++ TextInput: ui({+ name: 'TextInput',+ components: [+ { type: 'Transform' },+ { type: 'Image' },+ { type: 'UIRect', defaults: { size: { x: 200, y: 36 } } },+ { type: 'Interactable' },+ { type: 'TextInput' },+ ],+ }),++ // ---- Physics ----+ BoxCollider: physics({+ name: 'BoxCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'BoxCollider' }],+ }),++ CircleCollider: physics({+ name: 'CircleCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'CircleCollider' }],+ }),++ CapsuleCollider: physics({+ name: 'CapsuleCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'CapsuleCollider' }],+ }),++ SegmentCollider: physics({+ name: 'SegmentCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'SegmentCollider' }],+ }),++ PolygonCollider: physics({+ name: 'PolygonCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'PolygonCollider' }],+ }),++ ChainCollider: physics({+ name: 'ChainCollider',+ components: [{ type: 'Transform' }, { type: 'RigidBody' }, { type: 'ChainCollider' }],+ }),};+// =============================================================================+// Instantiation (category-driven, no type inspection)+// =============================================================================+export function instantiateTemplate(state: HierarchyState,templateName: string,@@ -203,9 +318,14 @@ export function instantiateTemplate(const template = ENTITY_TEMPLATES[templateName];if (!template) return null;+ let effectiveParent = parent;+ if (template.category === 'ui') {+ effectiveParent = resolveUIParent(state.store, parent);+ }+const refMap = new Map<string, Entity>();- const rootEntity = createNode(state, template.root, parent, refMap);+ const rootEntity = createNode(state, template.root, effectiveParent, refMap);if (template.bindings) {for (const [binding, ref] of Object.entries(template.bindings)) {diff --git a/editor/src/panels/hierarchy/HierarchyContextMenu.ts b/editor/src/panels/hierarchy/HierarchyContextMenu.tsindex 8b3b50666..151ffe016 100644--- a/editor/src/panels/hierarchy/HierarchyContextMenu.ts+++ b/editor/src/panels/hierarchy/HierarchyContextMenu.ts@@ -13,6 +13,9 @@ import { getAssetTypeDescriptor } from '../../asset/AssetTypeRegistry';import type { HierarchyState } from './HierarchyTypes';import { instantiateTemplate } from './EntityTemplates';+const create = (state: HierarchyState, template: string, parent: Entity | null) =>+ () => instantiateTemplate(state, template, parent);+export function showEntityContextMenu(state: HierarchyState, x: number, y: number, entity: Entity | null): void {const entityData = entity !== null ? state.store.getEntityData(entity as number) : null;const has = (type: string) => entityData?.components.some(c => c.type === type) ?? false;@@ -26,42 +29,42 @@ export function showEntityContextMenu(state: HierarchyState, x: number, y: numbe} },{ label: '', separator: true },{ label: '2D', icon: icons.image(14), children: [- { label: 'Sprite', icon: icons.image(14), onClick: () => createEntityWithComponent(state, 'Sprite', entity) },- { label: 'Text', icon: icons.type(14), onClick: () => createEntityWithComponent(state, 'Text', entity) },- { label: 'BitmapText', icon: icons.type(14), onClick: () => createEntityWithComponent(state, 'BitmapText', entity) },- { 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: () => instantiateTemplate(state, 'Tilemap', entity) },+ { label: 'Sprite', icon: icons.image(14), onClick: create(state, 'Sprite', entity) },+ { label: 'Text', icon: icons.type(14), onClick: create(state, 'Text', entity) },+ { label: 'BitmapText', icon: icons.type(14), onClick: create(state, 'BitmapText', entity) },+ { label: 'Spine', icon: icons.bone(14), onClick: create(state, 'SpineAnimation', entity) },+ { label: 'Shape', icon: icons.hexagon(14), onClick: create(state, 'ShapeRenderer', entity) },+ { label: 'Particle', icon: icons.star(14), onClick: create(state, 'ParticleEmitter', entity) },+ { label: 'Tilemap', icon: icons.grid(14), onClick: create(state, 'Tilemap', entity) },] },{ label: 'UI', icon: icons.pointer(14), children: [- { label: 'Canvas', icon: icons.template(14), onClick: () => createEntityWithComponent(state, 'Canvas', entity) },+ { label: 'Canvas', icon: icons.template(14), onClick: create(state, 'Canvas', entity) },{ label: '', separator: true },- { 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: () => instantiateTemplate(state, 'Image', entity) },- { label: 'Panel', icon: icons.layers(14), onClick: () => instantiateTemplate(state, 'Panel', entity) },+ { label: 'Button', icon: icons.pointer(14), onClick: create(state, 'Button', entity) },+ { label: 'TextInput', icon: icons.type(14), onClick: create(state, 'TextInput', entity) },+ { label: 'Image', icon: icons.image(14), onClick: create(state, 'Image', entity) },+ { label: 'Panel', icon: icons.layers(14), onClick: create(state, 'Panel', entity) },{ label: '', separator: true },- { 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: 'Toggle', icon: icons.toggle(14), onClick: create(state, 'Toggle', entity) },+ { label: 'Slider', icon: icons.sliders(14), onClick: create(state, 'Slider', entity) },+ { label: 'ProgressBar', icon: icons.gauge(14), onClick: create(state, 'ProgressBar', entity) },+ { label: 'ScrollView', icon: icons.list(14), onClick: create(state, 'ScrollView', entity) },+ { label: 'Dropdown', icon: icons.chevronDown(14), onClick: create(state, 'Dropdown', entity) },] },{ label: 'Audio', icon: icons.volume(14), children: [- { label: 'AudioSource', icon: icons.volume(14), onClick: () => createAudioEntity(state, 'AudioSource', entity) },- { label: 'AudioListener', icon: icons.headphones(14), onClick: () => createAudioEntity(state, 'AudioListener', entity) },+ { label: 'AudioSource', icon: icons.volume(14), onClick: create(state, 'AudioSource', entity) },+ { label: 'AudioListener', icon: icons.headphones(14), onClick: create(state, 'AudioListener', entity) },] },{ label: 'Physics', icon: icons.circle(14), children: [- { label: 'Box Collider', icon: icons.box(14), onClick: () => createPhysicsEntity(state, 'BoxCollider', entity) },- { label: 'Circle Collider', icon: icons.circle(14), onClick: () => createPhysicsEntity(state, 'CircleCollider', entity) },- { label: 'Capsule Collider', icon: icons.shield(14), onClick: () => createPhysicsEntity(state, 'CapsuleCollider', entity) },- { label: 'Segment Collider', icon: icons.minus(14), onClick: () => createPhysicsEntity(state, 'SegmentCollider', entity) },- { label: 'Polygon Collider', icon: icons.hexagon(14), onClick: () => createPhysicsEntity(state, 'PolygonCollider', entity) },- { label: 'Chain Collider', icon: icons.link(14), onClick: () => createPhysicsEntity(state, 'ChainCollider', entity) },+ { label: 'Box Collider', icon: icons.box(14), onClick: create(state, 'BoxCollider', entity) },+ { label: 'Circle Collider', icon: icons.circle(14), onClick: create(state, 'CircleCollider', entity) },+ { label: 'Capsule Collider', icon: icons.shield(14), onClick: create(state, 'CapsuleCollider', entity) },+ { label: 'Segment Collider', icon: icons.minus(14), onClick: create(state, 'SegmentCollider', entity) },+ { label: 'Polygon Collider', icon: icons.hexagon(14), onClick: create(state, 'PolygonCollider', entity) },+ { label: 'Chain Collider', icon: icons.link(14), onClick: create(state, 'ChainCollider', entity) },] },{ label: '', separator: true },- { label: 'Camera', icon: icons.camera(14), onClick: () => createEntityWithComponent(state, 'Camera', entity) },+ { label: 'Camera', icon: icons.camera(14), onClick: create(state, 'Camera', entity) },];const items: ContextMenuItem[] = [];@@ -199,56 +202,6 @@ export function showEntityContextMenu(state: HierarchyState, x: number, y: numbeshowContextMenu({ x, y, items });}-function createEntityWithComponent(state: HierarchyState, componentType: string, parent: Entity | null): void {- const newEntity = state.store.createEntity(componentType, parent);-- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));-- if (componentType === 'Text') {- const parentHasUIRect = parent !== null && state.store.getComponent(parent, 'UIRect') !== null;- if (parentHasUIRect) {- state.store.addComponent(newEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- anchorMin: { x: 0, y: 0 },- anchorMax: { x: 1, y: 1 },- size: { x: 0, y: 0 },- });- } else {- state.store.addComponent(newEntity, 'UIRect', getInitialComponentData('UIRect'));- }- }-- state.store.addComponent(newEntity, componentType, getInitialComponentData(componentType));-}--function createAudioEntity(state: HierarchyState, componentType: string, parent: Entity | null): void {- const newEntity = state.store.createEntity(componentType, parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, componentType, getInitialComponentData(componentType));-}--function createPhysicsEntity(state: HierarchyState, colliderType: string, parent: Entity | null): void {- const newEntity = state.store.createEntity(colliderType, parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- state.store.addComponent(newEntity, 'RigidBody', getInitialComponentData('RigidBody'));- state.store.addComponent(newEntity, colliderType, getInitialComponentData(colliderType));-}--function createTextInputEntity(state: HierarchyState, parent: Entity | null): void {- const newEntity = state.store.createEntity('TextInput', parent);- state.store.addComponent(newEntity, 'Transform', getInitialComponentData('Transform'));- const tiDefaults = getInitialComponentData('TextInput');- state.store.addComponent(newEntity, 'Image', {- ...getInitialComponentData('Image'),- color: tiDefaults.backgroundColor,- });- state.store.addComponent(newEntity, 'UIRect', {- ...getInitialComponentData('UIRect'),- size: { x: 200, y: 36 },- });- state.store.addComponent(newEntity, 'Interactable', getInitialComponentData('Interactable'));- state.store.addComponent(newEntity, 'TextInput', getInitialComponentData('TextInput'));-}export function duplicateEntity(state: HierarchyState, entity: Entity): void {const entityData = state.store.getEntityData(entity as number);diff --git a/editor/src/panels/hierarchy/uiEntityUtils.ts b/editor/src/panels/hierarchy/uiEntityUtils.tsnew file mode 100644index 000000000..deb826c4a--- /dev/null+++ b/editor/src/panels/hierarchy/uiEntityUtils.ts@@ -0,0 +1,21 @@+import type { Entity } from 'esengine';+import { getInitialComponentData } from '../../schemas/ComponentSchemas';+import type { EditorStore } from '../../store/EditorStore';++export function ensureCanvasEntity(store: EditorStore): Entity {+ for (const entity of store.scene.entities) {+ if (entity.components.some(c => c.type === 'Canvas')) {+ return entity.id as Entity;+ }+ }+ const canvas = store.createEntity('Canvas', null);+ store.addComponent(canvas, 'Transform', getInitialComponentData('Transform'));+ store.addComponent(canvas, 'UIRect', getInitialComponentData('UIRect'));+ store.addComponent(canvas, 'Canvas', getInitialComponentData('Canvas'));+ return canvas;+}++export function resolveUIParent(store: EditorStore, parent: Entity | null): Entity {+ if (parent !== null) return parent;+ return ensureCanvasEntity(store);+}diff --git a/editor/src/panels/inspector/EntityInspector.ts b/editor/src/panels/inspector/EntityInspector.tsindex a1646e62b..bf7dc38c8 100644--- a/editor/src/panels/inspector/EntityInspector.ts+++ b/editor/src/panels/inspector/EntityInspector.ts@@ -499,6 +499,7 @@ export function renderComponent(},componentData: component.data,getComponentValue: (name: string) => component.data[name],+ getCurrentValue: () => component.data[key] ?? defaults[key],});if (editor) {@@ -549,6 +550,7 @@ function renderPropertyRow(},componentData: component.data,getComponentValue: (name: string) => component.data[name],+ getCurrentValue: () => ({ ...defaults, ...component.data }),});if (editor) {@@ -613,6 +615,7 @@ function renderPropertyRow(},componentData: component.data,getComponentValue: (name: string) => component.data[name],+ getCurrentValue: () => component.data[propMeta.name] ?? defaults[propMeta.name],});if (editor) {diff --git a/editor/src/panels/scene-view/SceneViewPanel.ts b/editor/src/panels/scene-view/SceneViewPanel.tsindex 1959dec0e..26d7a0f14 100644--- a/editor/src/panels/scene-view/SceneViewPanel.ts+++ b/editor/src/panels/scene-view/SceneViewPanel.ts@@ -1,6 +1,5 @@import type { Entity, App } from 'esengine';import { Renderer, computeUIRectLayout, DEFAULT_SPRITE_SIZE, StatsCollector } from 'esengine';-import type { SpineModuleController } from 'esengine/spine';import type { EditorStore } from '../../store/EditorStore';import type { EditorBridge } from '../../bridge/EditorBridge';import { getPlatformAdapter } from '../../platform/PlatformAdapter';@@ -324,8 +323,7 @@ export class SceneViewPanel {}}- setSpineController(controller: SpineModuleController | null): void {- this.sceneRenderer_?.setSpineController(controller);+ setSpineController(_controller: unknown): void {}getSpineSkeletonInfo(entityId: number): { animations: string[]; skins: string[] } | null {@@ -407,6 +405,7 @@ export class SceneViewPanel {this.sceneRenderer_.setStore(this.store_);this.sceneRenderer_.setRenderCallback(() => this.requestRender());sharedCtx.setRenderCallback(() => this.requestRender());+ this.sceneRenderer_.onSpineInstanceReady(() => this.requestRender());this.webglInitialized_ = true;this.useWebGL_ = true;@@ -1004,7 +1003,7 @@ export class SceneViewPanel {if (!getSettingsValue<boolean>('scene.showStats') || !this.useWebGL_) return;const stats = Renderer.getStats();- const spineCount = this.sceneRenderer_?.spineInstanceCount ?? stats.spine;+ const spineCount = stats.spine;const fps = this.fpsCollector_.getFps();const entityCount = this.store_.scene.entities.length;diff --git a/editor/src/plugins/ui.ts b/editor/src/plugins/ui.tsindex 678daf2f4..02fa1cef5 100644--- a/editor/src/plugins/ui.ts+++ b/editor/src/plugins/ui.ts@@ -254,6 +254,13 @@ const DragStateSchema: ComponentSchema = {properties: [],};+const UIRendererSchema: ComponentSchema = {+ name: 'UIRenderer',+ category: 'ui',+ hidden: true,+ properties: [],+};+const UI_SCHEMAS: ComponentSchema[] = [UIRectSchema, UIMaskSchema, InteractableSchema, UIInteractionSchema,ButtonSchema, TextInputSchema, ImageSchema,@@ -262,6 +269,7 @@ const UI_SCHEMAS: ComponentSchema[] = [SafeAreaSchema, ListViewSchema, DropdownSchema,FlexContainerSchema, FlexItemSchema, LayoutGroupSchema,DragStateSchema,+ UIRendererSchema,];export const uiPlugin: EditorPlugin = {diff --git a/editor/src/property/PropertyEditor.ts b/editor/src/property/PropertyEditor.tsindex b25b2d33c..fa875a438 100644--- a/editor/src/property/PropertyEditor.ts+++ b/editor/src/property/PropertyEditor.ts@@ -37,6 +37,7 @@ export interface PropertyEditorContext {onChange: (value: unknown) => void;componentData?: Record<string, unknown>;getComponentValue?: (name: string) => unknown;+ getCurrentValue?: () => unknown;}export type PropertyEditorFactory = (