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.

fix(editor): repair four broken data-panel interactions

yhhd0c5aeaaec10
diff --git a/desktop/src/i18n/messages/content.ts b/desktop/src/i18n/messages/content.ts
index 0a41a6453..54ba5ff1e 100644
--- a/desktop/src/i18n/messages/content.ts
+++ b/desktop/src/i18n/messages/content.ts
@@ -50,7 +50,7 @@ export const contentMessages = defineMessages({
'cb.startupScene': { en: 'Startup scene', zh: '启动场景' },
'cb.excludedFromExport': { en: 'Excluded from export', zh: '已从导出中排除' },
'cb.footItems': { en: '{count} items', zh: '{count} 项' },
- 'cb.footItemsSelected': { en: '{count} items · 1 selected', zh: '{count} 项 · 已选中 1 个' },
+ 'cb.footItemsSelected': { en: '{count} items · {sel} selected', zh: '{count} 项 · 已选中 {sel} 个' },
// — Hover-card rows (labels; `cb.type` above is reused as a row label) —
'cb.tipFolder': { en: 'Folder', zh: '文件夹' },
@@ -122,6 +122,7 @@ export const contentMessages = defineMessages({
'cb.unsavedScene': { en: 'Untitled scene', zh: '未命名场景' },
'cb.unsavedMark': { en: 'unsaved', zh: '未保存' },
'cb.movedTo': { en: 'Moved “{name}” to {dest}', zh: '已将“{name}”移动到 {dest}' },
+ 'cb.movedCount': { en: 'Moved {count} items to {dest}', zh: '已移动 {count} 项到 {dest}' },
'cb.projectRoot': { en: 'the project root', zh: '项目根目录' },
'cb.moveFailed': { en: 'Move failed: {error}', zh: '移动失败:{error}' },
'cb.newFolderFailed': { en: 'New folder failed: {error}', zh: '新建文件夹失败:{error}' },
diff --git a/desktop/src/i18n/messages/details.ts b/desktop/src/i18n/messages/details.ts
index 63aeab1e1..4c067bf99 100644
--- a/desktop/src/i18n/messages/details.ts
+++ b/desktop/src/i18n/messages/details.ts
@@ -195,7 +195,7 @@ export const detailsMessages = defineMessages({
en: 'Select an entity in the scene, or an asset in the Content Browser.',
zh: '在场景中选择一个实体,或在内容浏览器中选择一个资产。',
},
- 'det.filterProps': { en: 'Filter properties', zh: '过滤属性' },
+ 'det.filterProps': { en: 'Show overridden only', zh: '只显示已修改的属性' },
'det.entitiesSelected': { en: '{count} entities selected', zh: '已选择 {count} 个实体' },
'det.editing': { en: 'Editing', zh: '编辑中' },
'det.editingShared': { en: '{count} entities · shared components', zh: '{count} 个实体 · 共同组件' },
diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsx
index 38581272b..ddc08617d 100644
--- a/desktop/src/panels/ContentBrowser.tsx
+++ b/desktop/src/panels/ContentBrowser.tsx
@@ -832,23 +832,51 @@ export function ContentBrowser() {
// Move an asset into a folder (drag onto a folder tile / tree node). Rename moves
// the `.meta` sidecar too, so uuid refs survive; rejects no-op and self/descendant
// moves. Refs are uuid-based, so nothing referencing the asset breaks.
- const moveAssetToFolder = async (srcPath: string, folderPath: string) => {
+ // Move one asset into a folder (no toast / refresh — the callers own those, so a
+ // batch move renames every file before one combined refresh + undo toast).
+ const doMoveAsset = async (srcPath: string, folderPath: string): Promise<string | null> => {
const name = srcPath.split('/').pop();
- if (!name) return;
+ if (!name) return null;
const dest = join(folderPath, name);
- if (dest === srcPath || srcPath === folderPath || folderPath.startsWith(`${srcPath}/`)) return;
+ if (dest === srcPath || srcPath === folderPath || folderPath.startsWith(`${srcPath}/`)) return null;
try {
await window.estella.fs.rename(srcPath, dest);
syncAssetPaths(srcPath, dest);
- refreshFs();
if (selected === srcPath) selectAsset(dest);
- Toasts.push(t('cb.movedTo', { name, dest: folderPath || t('cb.projectRoot') }), 'info', 6000, {
- label: t('cb.undo'),
- run: () => void undoMove(dest, srcPath),
- });
+ return dest;
} catch (e) {
Toasts.push(t('cb.moveFailed', { error: errMsg(e) }), 'error');
+ return null;
+ }
+ };
+
+ const moveAssetToFolder = async (srcPath: string, folderPath: string) => {
+ const dest = await doMoveAsset(srcPath, folderPath);
+ if (!dest) return;
+ refreshFs();
+ Toasts.push(t('cb.movedTo', { name: srcPath.split('/').pop() ?? srcPath, dest: folderPath || t('cb.projectRoot') }), 'info', 6000, {
+ label: t('cb.undo'),
+ run: () => void undoMove(dest, srcPath),
+ });
+ };
+
+ // Drag a multi-selection into a folder: move each, then ONE combined undo toast
+ // (reverses every move) — so a batch move is one calm, undoable operation.
+ const moveAssetsToFolder = async (srcPaths: string[], folderPath: string) => {
+ if (srcPaths.length <= 1) return moveAssetToFolder(srcPaths[0], folderPath);
+ const moved: { src: string; dest: string }[] = [];
+ for (const src of srcPaths) {
+ const dest = await doMoveAsset(src, folderPath);
+ if (dest) moved.push({ src, dest });
}
+ if (!moved.length) return;
+ refreshFs();
+ Toasts.push(t('cb.movedCount', { count: moved.length, dest: folderPath || t('cb.projectRoot') }), 'info', 6000, {
+ label: t('cb.undo'),
+ run: () => void (async () => {
+ for (const m of moved) await undoMove(m.dest, m.src);
+ })(),
+ });
};
// Drop-target props for a folder (tile, list row or tree node): accept internal
@@ -877,11 +905,13 @@ export function ContentBrowser() {
},
onDrop: (e: React.DragEvent) => {
clearDropState();
+ const multi = e.dataTransfer.getData('application/x-estella-assets');
const src = e.dataTransfer.getData('application/x-estella-asset');
- if (!src) return;
+ const paths: string[] = multi ? JSON.parse(multi) : src ? [src] : [];
+ if (!paths.length) return;
e.preventDefault();
e.stopPropagation();
- void moveAssetToFolder(src, folderPath);
+ void moveAssetsToFolder(paths, folderPath);
},
});
@@ -902,9 +932,17 @@ export function ContentBrowser() {
draggable: !e.isDir && renaming !== path,
onDragStart: (ev: React.DragEvent) => {
tip.close();
- ev.dataTransfer.effectAllowed = 'copy';
+ // copyMove: dropping into a folder MOVES; dropping into the scene / inspector
+ // COPIES (instantiate / assign a ref) — so both cursors read correctly.
+ ev.dataTransfer.effectAllowed = 'copyMove';
ev.dataTransfer.setData('application/x-estella-asset', path);
ev.dataTransfer.setData('text/plain', path);
+ // Grabbing one of several selected assets drags the whole selection. Only the
+ // folder-move reads this plural payload; single-asset consumers (assign a ref,
+ // instantiate) keep reading the singular one above.
+ if (selectedAssets.has(path) && selectedAssets.size > 1) {
+ ev.dataTransfer.setData('application/x-estella-assets', JSON.stringify([...selectedAssets]));
+ }
setDragPath(path);
},
// A cancelled drag (Escape / dropped outside a target) fires no drop —
@@ -1288,7 +1326,10 @@ export function ContentBrowser() {
<div className="cb-foot">
<span>
- {t(selected ? 'cb.footItemsSelected' : 'cb.footItems', { count: items.length })}
+ {t(selectedAssets.size > 0 ? 'cb.footItemsSelected' : 'cb.footItems', {
+ count: items.length,
+ sel: selectedAssets.size,
+ })}
</span>
<span className="sp" />
{view === 'grid' && (
diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsx
index ea59494b5..b29cedc11 100644
--- a/desktop/src/panels/Details.tsx
+++ b/desktop/src/panels/Details.tsx
@@ -2997,22 +2997,31 @@ function EditorDetails() {
[ready, ids, revision],
);
- // Inspector search: keep components whose name matches (all fields), or that
- // have any matching field (only the matches) — the Details filter behaviour.
+ // Inspector search + override filter. Search keeps components whose name matches
+ // (all fields) or that have a matching field (only the matches); the Filter toggle
+ // then narrows to overridden fields only — components with a value that differs
+ // from its default, keeping just those fields (Unity's "show overridden" mode).
const visible = useMemo(() => {
const q = query.trim().toLowerCase();
- if (!q) return components;
- const out: InspectorComponent[] = [];
- for (const c of components) {
- if (c.label.toLowerCase().includes(q)) {
- out.push(c);
- continue;
+ let out = components;
+ if (q) {
+ out = [];
+ for (const c of components) {
+ if (c.label.toLowerCase().includes(q)) {
+ out.push(c);
+ continue;
+ }
+ const fields = c.fields.filter((f) => f.label.toLowerCase().includes(q));
+ if (fields.length) out.push({ ...c, fields });
}
- const fields = c.fields.filter((f) => f.label.toLowerCase().includes(q));
- if (fields.length) out.push({ ...c, fields });
+ }
+ if (filtOn) {
+ out = out
+ .map((c) => ({ ...c, fields: c.fields.filter(isModified) }))
+ .filter((c) => c.fields.length > 0);
}
return out;
- }, [components, query]);
+ }, [components, query, filtOn]);
// An explicit sub-object inspection source (a keyframe, a track…) overrides the
// entity/asset inspector; a non-override source is the fallback further below.
@@ -3091,7 +3100,17 @@ function EditorDetails() {
e.currentTarget.blur();
}
}}
- onBlur={(e) => SceneCommands.renameEntity(selectedId, e.target.value)}
+ onBlur={(e) => {
+ // Trim, reject empty, and skip a no-op — clicking the name and
+ // clicking away must not blank it or log an empty undo step
+ // (matches the Outliner + Content Browser rename guards).
+ const next = e.target.value.trim();
+ if (!next || next === entity.name) {
+ e.target.value = entity.name;
+ return;
+ }
+ SceneCommands.renameEntity(selectedId, next);
+ }}
/>
)}
</div>