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: update editor UI and property editors
esengineea21234d6232
diff --git a/editor/src/asset/index.ts b/editor/src/asset/index.tsindex 0d29723f8..ba171202f 100644--- a/editor/src/asset/index.ts+++ b/editor/src/asset/index.ts@@ -9,6 +9,8 @@ export type { PathValidationResult } from './AssetPathResolver';export { AssetLoader } from './AssetLoader';export type { LoadResult } from './AssetLoader';+export { EditorAssetServer } from './EditorAssetServer';+import { AssetPathResolver } from './AssetPathResolver';let globalPathResolver: AssetPathResolver | null = null;diff --git a/editor/src/panels/ContentBrowserPanel.ts b/editor/src/panels/ContentBrowserPanel.tsindex eb91042b3..3e97292a7 100644--- a/editor/src/panels/ContentBrowserPanel.ts+++ b/editor/src/panels/ContentBrowserPanel.ts@@ -43,7 +43,7 @@ interface FolderNode {interface AssetItem {name: string;path: string;- type: 'folder' | 'scene' | 'script' | 'image' | 'audio' | 'json' | 'file';+ type: 'folder' | 'scene' | 'script' | 'image' | 'audio' | 'json' | 'spine' | 'file';}export interface ContentBrowserOptions {@@ -98,6 +98,9 @@ function getAssetType(entry: DirectoryEntry): AssetItem['type'] {return 'audio';case '.json':return 'json';+ case '.skel':+ case '.atlas':+ return 'spine';default:return 'file';}@@ -117,6 +120,8 @@ function getAssetIcon(type: AssetItem['type'], size: number = 32): string {return icons.volume(size);case 'json':return icons.braces(size);+ case 'spine':+ return icons.bone(size);default:return icons.file(size);}@@ -433,6 +438,34 @@ export class ContentBrowserPanel {this.showFolderContextMenu(e, path);}});++ this.gridContainer_?.addEventListener('dragstart', (e) => {+ const target = e.target as HTMLElement;+ const item = target.closest('.es-asset-item') as HTMLElement;+ if (!item) return;++ const path = item.dataset.path;+ const type = item.dataset.type;+ if (!path || !type) return;++ const assetData = this.currentItems_.find(i => i.path === path);+ if (!assetData) return;++ e.dataTransfer?.setData('application/esengine-asset', JSON.stringify({+ type: type,+ path: path,+ name: assetData.name,+ }));+ e.dataTransfer!.effectAllowed = 'copy';++ item.classList.add('es-dragging');+ });++ this.gridContainer_?.addEventListener('dragend', (e) => {+ const target = e.target as HTMLElement;+ const item = target.closest('.es-asset-item') as HTMLElement;+ item?.classList.remove('es-dragging');+ });}private showAssetContextMenu(e: MouseEvent, path: string, type: AssetItem['type']): void {@@ -623,10 +656,16 @@ export class ContentBrowserPanel {);}+ const isDraggable = (type: AssetItem['type']) =>+ type === 'spine' || type === 'image' || type === 'json';+this.gridContainer_.innerHTML = filteredItems.map((item) => `- <div class="es-asset-item${item.path === this.selectedAssetPath_ ? ' es-selected' : ''}" data-path="${item.path}" data-type="${item.type}">+ <div class="es-asset-item${item.path === this.selectedAssetPath_ ? ' es-selected' : ''}"+ data-path="${item.path}"+ data-type="${item.type}"+ ${isDraggable(item.type) ? 'draggable="true"' : ''}><div class="es-asset-icon">${getAssetIcon(item.type)}</div><div class="es-asset-name">${item.name}</div></div>diff --git a/editor/src/property/PropertyEditor.ts b/editor/src/property/PropertyEditor.tsindex 1e1a9d8b7..7b85208b7 100644--- a/editor/src/property/PropertyEditor.ts+++ b/editor/src/property/PropertyEditor.ts@@ -14,12 +14,16 @@ export interface PropertyMeta {max?: number;step?: number;options?: { label: string; value: unknown }[];+ fileFilter?: string[];+ dependsOn?: string;}export interface PropertyEditorContext {value: unknown;meta: PropertyMeta;onChange: (value: unknown) => void;+ componentData?: Record<string, unknown>;+ getComponentValue?: (name: string) => unknown;}export type PropertyEditorFactory = (diff --git a/editor/src/property/editors.ts b/editor/src/property/editors.tsindex 67273a0c4..c35e97141 100644--- a/editor/src/property/editors.ts+++ b/editor/src/property/editors.ts@@ -652,6 +652,7 @@ function createEnumEditor(// =============================================================================interface NativeFS {+ readFile(path: string): Promise<string | null>;readBinaryFile(path: string): Promise<Uint8Array | null>;}@@ -911,6 +912,294 @@ function createFontEditor(};}+// =============================================================================+// Spine File Editor+// =============================================================================++function createSpineFileEditor(+ container: HTMLElement,+ ctx: PropertyEditorContext+): PropertyEditorInstance {+ const { value, meta, onChange } = ctx;+ const fileFilter = meta.fileFilter ?? ['.json', '.skel'];++ const wrapper = document.createElement('div');+ wrapper.className = 'es-file-editor';++ const input = document.createElement('input');+ input.type = 'text';+ input.className = 'es-input es-input-file';+ input.value = String(value ?? '');+ input.placeholder = 'None';++ const browseBtn = document.createElement('button');+ browseBtn.className = 'es-btn es-btn-icon es-btn-browse';+ browseBtn.title = 'Browse';+ browseBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-6l-2-2H5a2 2 0 0 0-2 2z"></path></svg>`;++ input.addEventListener('change', () => {+ onChange(input.value || '');+ });++ browseBtn.addEventListener('click', async () => {+ const projectDir = getProjectDir();+ if (!projectDir) return;++ const assetsDir = `${projectDir}/assets`;++ try {+ const platform = getPlatformAdapter();+ const extensions = fileFilter.map(f => f.replace('.', ''));+ const result = await platform.openFileDialog({+ title: 'Select File',+ defaultPath: assetsDir,+ filters: [{ name: 'Spine Files', extensions }],+ });+ if (result) {+ const normalizedPath = result.replace(/\\/g, '/');+ const assetsIndex = normalizedPath.indexOf('/assets/');+ if (assetsIndex !== -1) {+ const relativePath = normalizedPath.substring(assetsIndex + 1);+ input.value = relativePath;+ onChange(relativePath);+ }+ }+ } catch (err) {+ console.error('Failed to open file dialog:', err);+ }+ });++ wrapper.appendChild(input);+ wrapper.appendChild(browseBtn);+ container.appendChild(wrapper);++ return {+ update(v: unknown) {+ input.value = String(v ?? '');+ },+ dispose() {+ wrapper.remove();+ },+ };+}++// =============================================================================+// Spine Animation Editor (dynamic dropdown from skeleton file)+// =============================================================================++interface SpineSkeletonData {+ animations?: Record<string, unknown>;+ skins?: Array<{ name: string }> | Record<string, unknown>;+}++async function loadSpineSkeletonData(skeletonPath: string): Promise<SpineSkeletonData | null> {+ if (!skeletonPath) return null;++ const projectDir = getProjectDir();+ const fs = getNativeFS();+ if (!projectDir || !fs) return null;++ const fullPath = `${projectDir}/${skeletonPath}`;++ try {+ const content = await fs.readFile(fullPath);+ if (!content) return null;+ return JSON.parse(content) as SpineSkeletonData;+ } catch (err) {+ console.warn('Failed to load spine skeleton:', err);+ return null;+ }+}++function getAnimationNames(data: SpineSkeletonData): string[] {+ if (!data.animations) return [];+ return Object.keys(data.animations);+}++function getSkinNames(data: SpineSkeletonData): string[] {+ if (!data.skins) return [];+ if (Array.isArray(data.skins)) {+ return data.skins.map(s => s.name);+ }+ return Object.keys(data.skins);+}++function createSpineAnimationEditor(+ container: HTMLElement,+ ctx: PropertyEditorContext+): PropertyEditorInstance {+ const { value, onChange, getComponentValue } = ctx;++ const wrapper = document.createElement('div');+ wrapper.className = 'es-spine-animation-editor';++ const select = document.createElement('select');+ select.className = 'es-input es-input-select';++ const refreshBtn = document.createElement('button');+ refreshBtn.className = 'es-btn es-btn-icon es-btn-refresh';+ refreshBtn.title = 'Refresh animations';+ refreshBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 2v6h-6M3 12a9 9 0 0 1 15-6.7L21 8M3 22v-6h6M21 12a9 9 0 0 1-15 6.7L3 16"></path></svg>`;++ let currentAnimations: string[] = [];++ const updateOptions = (animations: string[], currentValue: string) => {+ select.innerHTML = '';++ const emptyOption = document.createElement('option');+ emptyOption.value = '';+ emptyOption.textContent = '(None)';+ select.appendChild(emptyOption);++ for (const anim of animations) {+ const option = document.createElement('option');+ option.value = anim;+ option.textContent = anim;+ if (anim === currentValue) {+ option.selected = true;+ }+ select.appendChild(option);+ }++ currentAnimations = animations;+ };++ const loadAnimations = async () => {+ const skeletonPath = getComponentValue?.('skeletonPath') as string;+ if (!skeletonPath) {+ updateOptions([], String(value ?? ''));+ return;+ }++ const data = await loadSpineSkeletonData(skeletonPath);+ if (data) {+ const animations = getAnimationNames(data);+ updateOptions(animations, String(value ?? ''));+ } else {+ updateOptions([], String(value ?? ''));+ }+ };++ select.addEventListener('change', () => {+ onChange(select.value);+ });++ refreshBtn.addEventListener('click', () => {+ loadAnimations();+ });++ wrapper.appendChild(select);+ wrapper.appendChild(refreshBtn);+ container.appendChild(wrapper);++ loadAnimations();++ return {+ update(v: unknown) {+ const newValue = String(v ?? '');+ if (currentAnimations.includes(newValue) || newValue === '') {+ select.value = newValue;+ } else {+ loadAnimations();+ }+ },+ dispose() {+ wrapper.remove();+ },+ };+}++// =============================================================================+// Spine Skin Editor (dynamic dropdown from skeleton file)+// =============================================================================++function createSpineSkinEditor(+ container: HTMLElement,+ ctx: PropertyEditorContext+): PropertyEditorInstance {+ const { value, onChange, getComponentValue } = ctx;++ const wrapper = document.createElement('div');+ wrapper.className = 'es-spine-skin-editor';++ const select = document.createElement('select');+ select.className = 'es-input es-input-select';++ const refreshBtn = document.createElement('button');+ refreshBtn.className = 'es-btn es-btn-icon es-btn-refresh';+ refreshBtn.title = 'Refresh skins';+ refreshBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 2v6h-6M3 12a9 9 0 0 1 15-6.7L21 8M3 22v-6h6M21 12a9 9 0 0 1-15 6.7L3 16"></path></svg>`;++ let currentSkins: string[] = [];++ const updateOptions = (skins: string[], currentValue: string) => {+ select.innerHTML = '';++ for (const skin of skins) {+ const option = document.createElement('option');+ option.value = skin;+ option.textContent = skin;+ if (skin === currentValue) {+ option.selected = true;+ }+ select.appendChild(option);+ }++ if (skins.length === 0) {+ const defaultOption = document.createElement('option');+ defaultOption.value = 'default';+ defaultOption.textContent = 'default';+ select.appendChild(defaultOption);+ }++ currentSkins = skins;+ };++ const loadSkins = async () => {+ const skeletonPath = getComponentValue?.('skeletonPath') as string;+ if (!skeletonPath) {+ updateOptions(['default'], String(value ?? 'default'));+ return;+ }++ const data = await loadSpineSkeletonData(skeletonPath);+ if (data) {+ const skins = getSkinNames(data);+ updateOptions(skins.length > 0 ? skins : ['default'], String(value ?? 'default'));+ } else {+ updateOptions(['default'], String(value ?? 'default'));+ }+ };++ select.addEventListener('change', () => {+ onChange(select.value);+ });++ refreshBtn.addEventListener('click', () => {+ loadSkins();+ });++ wrapper.appendChild(select);+ wrapper.appendChild(refreshBtn);+ container.appendChild(wrapper);++ loadSkins();++ return {+ update(v: unknown) {+ const newValue = String(v ?? 'default');+ if (currentSkins.includes(newValue)) {+ select.value = newValue;+ } else {+ loadSkins();+ }+ },+ dispose() {+ wrapper.remove();+ },+ };+}+// =============================================================================// Register All Editors// =============================================================================@@ -927,4 +1216,7 @@ export function registerBuiltinEditors(): void {registerPropertyEditor('euler', createEulerEditor);registerPropertyEditor('texture', createTextureEditor);registerPropertyEditor('font', createFontEditor);+ registerPropertyEditor('spine-file', createSpineFileEditor);+ registerPropertyEditor('spine-animation', createSpineAnimationEditor);+ registerPropertyEditor('spine-skin', createSpineSkinEditor);}diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex b9471121d..345d30e76 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -394,6 +394,17 @@ svg {color: #d19a66;}+.es-hierarchy-item.es-drag-over > .es-hierarchy-row {+ background: rgba(97, 175, 239, 0.3);+ border-left-color: #61afef;+}++.es-hierarchy-tree.es-drag-over {+ background: rgba(97, 175, 239, 0.1);+ outline: 1px dashed #61afef;+ outline-offset: -2px;+}+.es-hierarchy-visibility {width: 16px;display: inline-flex;@@ -1491,6 +1502,18 @@ svg {background: rgba(209, 154, 102, 0.2);}+.es-asset-item.es-dragging {+ opacity: 0.5;+}++.es-asset-item[draggable="true"] {+ cursor: grab;+}++.es-asset-item[draggable="true"]:active {+ cursor: grabbing;+}+.es-asset-icon {display: flex;align-items: center;@@ -2441,6 +2464,48 @@ svg {flex-shrink: 0;}+/* =============================================================================+ * Spine File Editor+ * ============================================================================= */++.es-file-editor {+ display: flex;+ gap: 4px;+}++.es-file-editor .es-input-file {+ flex: 1;+ min-width: 0;+}++.es-file-editor .es-btn-browse {+ flex-shrink: 0;+}++/* =============================================================================+ * Spine Animation/Skin Editor+ * ============================================================================= */++.es-spine-animation-editor,+.es-spine-skin-editor {+ display: flex;+ gap: 4px;+}++.es-spine-animation-editor .es-input-select,+.es-spine-skin-editor .es-input-select {+ flex: 1;+ min-width: 0;+}++.es-btn-refresh {+ flex-shrink: 0;+}++.es-btn-refresh:hover {+ color: var(--es-accent);+}+/* =============================================================================* Build Settings Dialog* ============================================================================= */diff --git a/editor/src/utils/icons.ts b/editor/src/utils/icons.tsindex 07a3eb6cc..2c4415859 100644--- a/editor/src/utils/icons.ts+++ b/editor/src/utils/icons.ts@@ -48,6 +48,7 @@ import {Upload,Download,LayoutTemplate,+ Bone,} from 'lucide';// =============================================================================@@ -147,6 +148,7 @@ export const icons = {upload: (size?: number) => renderIcon(Upload as IconNode, size),download: (size?: number) => renderIcon(Download as IconNode, size),template: (size?: number) => renderIcon(LayoutTemplate as IconNode, size),+ bone: (size?: number) => renderIcon(Bone as IconNode, size),};export type IconName = keyof typeof icons;