Skip to content

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

feat(editor): multi-selection editing in Details

esenginee163448bd5b8
diff --git a/desktop/src/engine/SceneQuery.ts b/desktop/src/engine/SceneQuery.ts
index 4855d2afd..d8ad7338c 100644
--- a/desktop/src/engine/SceneQuery.ts
+++ b/desktop/src/engine/SceneQuery.ts
@@ -77,6 +77,52 @@ export function buildInspector(
return out;
}
+/** Structural value equality for raw component data (numbers, vecs, colors, …). */
+function deepEqual(a: unknown, b: unknown): boolean {
+ if (a === b) return true;
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;
+ const ka = Object.keys(a as object);
+ const kb = Object.keys(b as object);
+ if (ka.length !== kb.length) return false;
+ return ka.every((k) => deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]));
+}
+
+/**
+ * Multi-selection inspector: only the components shared by EVERY selected entity,
+ * with fields read from the primary (ids[0]). A field whose value differs across
+ * the selection is flagged `mixed`. Falls back to the single-entity inspector for
+ * 0/1 ids. `baseOf` is the primary's prefab base (reset target).
+ */
+export function buildMultiInspector(
+ data: SceneData | null,
+ ids: EntityId[],
+ baseOf?: (comp: string) => Record<string, unknown> | undefined,
+): InspectorComponent[] {
+ if (ids.length <= 1) return buildInspector(data, ids[0], baseOf);
+ const entities = ids
+ .map((id) => data?.entities.find((e) => e.id === id))
+ .filter((e): e is NonNullable<typeof e> => !!e);
+ if (entities.length <= 1) return buildInspector(data, ids[0], baseOf);
+ const primary = entities[0];
+ const dataOf = (e: typeof primary, name: string): Record<string, unknown> =>
+ (e.components.find((c) => c.type === name)?.data as Record<string, unknown>) ?? {};
+ const out: InspectorComponent[] = [];
+ for (const { name, label } of modelInspectableComponents(primary)) {
+ if (!entities.every((e) => e.components.some((c) => c.type === name))) continue; // shared only
+ const datas = entities.map((e) => dataOf(e, name));
+ const enableBase = componentEnable(name, datas[0]) ?? undefined;
+ const enable = enableBase
+ ? { ...enableBase, mixed: !datas.every((d) => (componentEnable(name, d)?.value ?? enableBase.value) === enableBase.value) }
+ : undefined;
+ const fields = inspectorFields(name, datas[0], baseOf?.(name)).filter((f) => f.key !== enable?.key);
+ for (const f of fields) {
+ if (!datas.every((d) => deepEqual(d[f.key], datas[0][f.key]))) f.mixed = true;
+ }
+ out.push({ name, label, fields, enable });
+ }
+ return out;
+}
+
/**
* Read-only projection of the editor's source-of-truth model into view-models.
* The outliner tree, inspector, and field reads
@@ -121,6 +167,15 @@ export class SceneQueryImpl {
return buildInspector(this.model.current, id, this.prefabBaseOf(id));
}
+ /**
+ * Multi-selection inspector: the components shared by every selected entity,
+ * fields read from the primary (ids[0]) and flagged `mixed` where the selection
+ * disagrees. Edits fan out to all; the reset target is the primary's base.
+ */
+ readMultiInspector(ids: EntityId[]): InspectorComponent[] {
+ return buildMultiInspector(this.model.current, ids, this.prefabBaseOf(ids[0]));
+ }
+
/**
* The prefab-instance base for an entity: a per-component lookup into the prefab
* asset's data, so the inspector marks/resets fields against the prefab (the UE
diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsx
index db2b31497..6f5f64b25 100644
--- a/desktop/src/panels/Details.tsx
+++ b/desktop/src/panels/Details.tsx
@@ -138,20 +138,23 @@ function useScrub(value: number, onCommit: (n: number) => void, opts: ScrubOpts
};
}
-// Plain click-to-type numeric input. `suffix` (e.g. °) shows in the resting value.
+// Plain click-to-type numeric input. `suffix` (e.g. °) shows in the resting value;
+// `mixed` (multi-select disagreement) shows a "—" placeholder until typed over.
function NumField({
value,
suffix,
+ mixed,
onBegin,
onEnd,
onCommit,
-}: ControlGesture & { value: number; suffix?: string; onCommit: (n: number) => void }) {
+}: ControlGesture & { value: number; suffix?: string; mixed?: boolean; onCommit: (n: number) => void }) {
const [editing, setEditing] = useState(false);
const [text, setText] = useState('');
return (
<span className="field">
<input
- value={editing ? text : fmt(value) + (suffix ?? '')}
+ value={editing ? text : mixed ? '' : fmt(value) + (suffix ?? '')}
+ placeholder={mixed ? '—' : undefined}
spellCheck={false}
onFocus={() => {
setText(fmt(value));
@@ -176,10 +179,11 @@ function NumField({
function VecField({
axis,
value,
+ mixed,
onBegin,
onEnd,
onCommit,
-}: ControlGesture & { axis: string; value: number; onCommit: (n: number) => void }) {
+}: ControlGesture & { axis: string; value: number; mixed?: boolean; onCommit: (n: number) => void }) {
const scrub = useScrub(value, onCommit, { onBegin, onEnd });
const [editing, setEditing] = useState(false);
const [text, setText] = useState('');
@@ -189,7 +193,8 @@ function VecField({
{axis.toUpperCase()}
</i>
<input
- value={editing ? text : fmt(value)}
+ value={editing ? text : mixed ? '' : fmt(value)}
+ placeholder={mixed ? '—' : undefined}
spellCheck={false}
onFocus={() => {
setText(fmt(value));
@@ -212,10 +217,11 @@ function VecField({
function VecControl({
value,
+ mixed,
onBegin,
onEnd,
onChange,
-}: ControlGesture & { value: number[]; onChange: (v: number[]) => void }) {
+}: ControlGesture & { value: number[]; mixed?: boolean; onChange: (v: number[]) => void }) {
return (
<div className="vec">
{value.map((n, i) => (
@@ -223,6 +229,7 @@ function VecControl({
key={i}
axis={AXES[i]}
value={n}
+ mixed={mixed}
onBegin={onBegin}
onEnd={onEnd}
onCommit={(v) => {
@@ -242,22 +249,24 @@ function VecControl({
function EnumControl({
value,
options,
+ mixed,
onBegin,
onEnd,
onChange,
-}: ControlGesture & { value: number; options: EnumOption[]; onChange: (v: number) => void }) {
+}: ControlGesture & { value: number; options: EnumOption[]; mixed?: boolean; onChange: (v: number) => void }) {
const known = options.some((o) => o.value === value);
return (
<span className="field">
<select
- value={String(value)}
+ value={mixed ? '' : String(value)}
onChange={(e) => {
onBegin?.();
onChange(Number(e.target.value));
onEnd?.();
}}
>
- {!known && <option value={String(value)}>{`(${value})`}</option>}
+ {mixed && <option value="">—</option>}
+ {!mixed && !known && <option value={String(value)}>{`(${value})`}</option>}
{options.map((o) => (
<option key={o.value} value={String(o.value)}>
{prettyLabel(o.label)}
@@ -335,18 +344,20 @@ function SliderControl({
function BoolControl({
value,
+ mixed,
onBegin,
onEnd,
onChange,
-}: ControlGesture & { value: boolean; onChange: (v: boolean) => void }) {
+}: ControlGesture & { value: boolean; mixed?: boolean; onChange: (v: boolean) => void }) {
return (
<span
- className={`toggle${value ? ' on' : ''}`}
+ className={`toggle${value ? ' on' : ''}${mixed ? ' mixed' : ''}`}
role="switch"
- aria-checked={value}
+ aria-checked={mixed ? 'mixed' : value}
onClick={() => {
onBegin?.();
- onChange(!value);
+ // From a mixed state, the first click commits everyone to enabled.
+ onChange(mixed ? true : !value);
onEnd?.();
}}
/>
@@ -355,16 +366,18 @@ function BoolControl({
function StringControl({
value,
+ mixed,
onBegin,
onEnd,
onChange,
-}: ControlGesture & { value: string; onChange: (v: string) => void }) {
+}: ControlGesture & { value: string; mixed?: boolean; onChange: (v: string) => void }) {
const [editing, setEditing] = useState(false);
const [text, setText] = useState('');
return (
<span className="field">
<input
- value={editing ? text : value}
+ value={editing ? text : mixed ? '' : value}
+ placeholder={mixed ? '—' : undefined}
spellCheck={false}
onFocus={() => {
setText(value);
@@ -483,17 +496,21 @@ function AssetControl({
// instead of the undoable SceneCommands path). When set, gestures are no-ops.
type FieldWrite = (key: string, type: InspectorField['type'], value: number | boolean | string | number[]) => void;
-function FieldRow({ entity, comp, field, write }: { entity: EntityId; comp: string; field: InspectorField; write?: FieldWrite }) {
+function FieldRow({ entities, comp, field, write }: { entities: EntityId[]; comp: string; field: InspectorField; write?: FieldWrite }) {
const ranged = field.min != null || field.max != null;
+ const mixed = field.mixed === true;
const clamp = (n: number) => {
let v = n;
if (field.min != null) v = Math.max(field.min, v);
if (field.max != null) v = Math.min(field.max, v);
return v;
};
+ // An edit fans out to every selected entity (the open gesture coalesces them
+ // into one undo step); the live "Game" inspector routes to the realm instead.
const apply = (value: number | boolean | string | number[]) => {
const v = ranged && typeof value === 'number' ? clamp(value) : value;
- return write ? write(field.key, field.type, v) : SceneCommands.setField(entity, comp, field.key, field.type, v as never);
+ if (write) return write(field.key, field.type, v);
+ for (const e of entities) SceneCommands.setField(e, comp, field.key, field.type, v as never);
};
const begin = () => (write ? undefined : SceneCommands.beginGesture(`Edit ${field.label}`));
const end = () => (write ? undefined : SceneCommands.endGesture());
@@ -525,24 +542,25 @@ function FieldRow({ entity, comp, field, write }: { entity: EntityId; comp: stri
onChange={apply}
/>
) : (
- <NumField value={field.value as number} suffix={field.unit} onBegin={begin} onEnd={end} onCommit={apply} />
+ <NumField value={field.value as number} suffix={field.unit} mixed={mixed} onBegin={begin} onEnd={end} onCommit={apply} />
);
break;
case 'angle':
- control = <NumField value={field.value as number} suffix="°" onBegin={begin} onEnd={end} onCommit={apply} />;
+ control = <NumField value={field.value as number} suffix="°" mixed={mixed} onBegin={begin} onEnd={end} onCommit={apply} />;
break;
case 'vec2':
case 'vec3':
- control = <VecControl value={field.value as number[]} onBegin={begin} onEnd={end} onChange={apply} />;
+ control = <VecControl value={field.value as number[]} mixed={mixed} onBegin={begin} onEnd={end} onChange={apply} />;
break;
case 'bool':
- control = <BoolControl value={field.value as boolean} onBegin={begin} onEnd={end} onChange={apply} />;
+ control = <BoolControl value={field.value as boolean} mixed={mixed} onBegin={begin} onEnd={end} onChange={apply} />;
break;
case 'enum':
control = (
<EnumControl
value={field.value as number}
options={field.options ?? []}
+ mixed={mixed}
onBegin={begin}
onEnd={end}
onChange={apply}
@@ -564,10 +582,10 @@ function FieldRow({ entity, comp, field, write }: { entity: EntityId; comp: stri
);
break;
default:
- control = <StringControl value={String(field.value)} onBegin={begin} onEnd={end} onChange={apply} />;
+ control = <StringControl value={String(field.value)} mixed={mixed} onBegin={begin} onEnd={end} onChange={apply} />;
}
- const modified = isModified(field);
+ const modified = !mixed && isModified(field);
const reset = () => {
if (field.defaultValue === undefined) return;
begin();
@@ -576,7 +594,7 @@ function FieldRow({ entity, comp, field, write }: { entity: EntityId; comp: stri
};
return (
- <div className={`prop${modified ? ' modified' : ''}`}>
+ <div className={`prop${modified ? ' modified' : ''}${mixed ? ' mixed' : ''}`}>
<span className={`prop-label${isScalar ? ' scrub' : ''}`} {...(isScalar ? labelScrub : {})}>
{field.label}
</span>
@@ -595,14 +613,14 @@ function FieldRow({ entity, comp, field, write }: { entity: EntityId; comp: stri
}
function ComponentSection({
- entity,
+ entities,
comp,
collapsed,
onToggle,
onMore,
write,
}: {
- entity: EntityId;
+ entities: EntityId[];
comp: InspectorComponent;
collapsed: boolean;
onToggle: () => void;
@@ -616,14 +634,20 @@ function ComponentSection({
const advanced = comp.fields.filter((f) => f.advanced);
const enable = comp.enable;
const on = !enable || enable.value;
- // The header checkbox toggles the component's enable field (one undo step), or
- // is a static "always on" for components that can't be disabled (e.g. Transform).
+ // The header checkbox toggles the component's enable field across the whole
+ // selection (one undo step), or is a static "always on" for components that
+ // can't be disabled (e.g. Transform). From a mixed state, the first click enables all.
const toggleEnable = (e: React.MouseEvent) => {
e.stopPropagation();
if (!enable) return;
- const next = !enable.value;
- if (write) write(enable.key, 'bool', next);
- else SceneCommands.setField(entity, comp.name, enable.key, 'bool', next);
+ const next = enable.mixed ? true : !enable.value;
+ if (write) {
+ write(enable.key, 'bool', next);
+ return;
+ }
+ SceneCommands.beginGesture(`Toggle ${comp.label}`);
+ for (const id of entities) SceneCommands.setField(id, comp.name, enable.key, 'bool', next);
+ SceneCommands.endGesture();
};
return (
<section className={`comp${collapsed ? '' : ' open'}${overridden ? ' override' : ''}${enable && !on ? ' disabled' : ''}`}>
@@ -632,9 +656,9 @@ function ComponentSection({
<ChevronRight size={9} strokeWidth={3} />
</span>
<span
- className={`comp-chk${on ? ' on' : ''}`}
+ className={`comp-chk${on ? ' on' : ''}${enable?.mixed ? ' mixed' : ''}`}
role={enable ? 'checkbox' : undefined}
- aria-checked={enable ? enable.value : undefined}
+ aria-checked={enable ? (enable.mixed ? 'mixed' : enable.value) : undefined}
title={enable ? (enable.value ? 'Disable component' : 'Enable component') : undefined}
onClick={enable ? toggleEnable : (e) => e.stopPropagation()}
>
@@ -662,7 +686,7 @@ function ComponentSection({
<div className="cinner">
<div className="comp-fields">
{primary.map((f) => (
- <FieldRow key={f.key} entity={entity} comp={comp.name} field={f} write={write} />
+ <FieldRow key={f.key} entities={entities} comp={comp.name} field={f} write={write} />
))}
{advanced.length > 0 && (
<>
@@ -673,7 +697,7 @@ function ComponentSection({
<div className="subbody">
<div>
{advanced.map((f) => (
- <FieldRow key={f.key} entity={entity} comp={comp.name} field={f} write={write} />
+ <FieldRow key={f.key} entities={entities} comp={comp.name} field={f} write={write} />
))}
</div>
</div>
@@ -728,7 +752,7 @@ function GameDetails() {
{inspector.map((comp) => (
<ComponentSection
key={comp.name}
- entity={selection}
+ entities={[selection]}
comp={comp}
collapsed={collapsed.has(comp.name)}
onToggle={() => toggle(comp.name)}
@@ -813,9 +837,20 @@ function EditorDetails() {
// Re-render when a project component's schema changes (live edit of its source).
useSyncExternalStore(subscribeSchemas, getSchemaRevision);
const selectedId = useSelection((s) => s.selectedId);
+ const selectedIds = useSelection((s) => s.selectedIds);
const selectedAsset = useSelection((s) => s.selectedAsset);
const ready = engine.status === 'ready' && selectedId != null;
+ // Selection targets, primary (the active id) first. Edits fan out across all.
+ const ids = useMemo(
+ () => (selectedId == null ? [] : [selectedId, ...[...selectedIds].filter((i) => i !== selectedId)]),
+ [selectedId, selectedIds],
+ );
+ const multi = ids.length > 1;
+ // Apply a structural command to every selected entity. Field edits coalesce into
+ // one undo step via the gesture; add/remove component record per entity.
+ const fanOut = (action: (id: EntityId) => void) => ids.forEach(action);
+
const [query, setQuery] = useState('');
const [collapsed, setCollapsed] = useState<Set<string>>(new Set());
const [compMenu, setCompMenu] = useState<{ x: number; y: number; comp: string } | null>(null);
@@ -833,8 +868,8 @@ function EditorDetails() {
[ready, selectedId, revision],
);
const components = useMemo(
- () => (ready ? SceneQuery.readInspector(selectedId!) : []),
- [ready, selectedId, revision],
+ () => (ready ? SceneQuery.readMultiInspector(ids) : []),
+ [ready, ids, revision],
);
// Inspector search: keep components whose name matches (all fields), or that
@@ -908,25 +943,38 @@ function EditorDetails() {
<div className="ent-head">
<div className="ent-row1">
- <input
- key={selectedId}
- className="ent-name"
- defaultValue={entity.name}
- spellCheck={false}
- onBlur={(e) => SceneCommands.renameEntity(selectedId, e.target.value)}
- />
+ {multi ? (
+ <div className="ent-name ent-multi">{ids.length} entities selected</div>
+ ) : (
+ <input
+ key={selectedId}
+ className="ent-name"
+ defaultValue={entity.name}
+ spellCheck={false}
+ onBlur={(e) => SceneCommands.renameEntity(selectedId, e.target.value)}
+ />
+ )}
</div>
<div className="ent-meta">
- <span className="pill">
- <span className="pk">Type</span>
- {KIND_LABEL[entity.kind]}
- </span>
- <span className="pill">
- <span className="pk">ID</span>
- {selectedId}
- </span>
+ {multi ? (
+ <span className="pill">
+ <span className="pk">Editing</span>
+ {ids.length} entities · shared components
+ </span>
+ ) : (
+ <>
+ <span className="pill">
+ <span className="pk">Type</span>
+ {KIND_LABEL[entity.kind]}
+ </span>
+ <span className="pill">
+ <span className="pk">ID</span>
+ {selectedId}
+ </span>
+ </>
+ )}
</div>
- {prefabName && (
+ {prefabName && !multi && (
<div className="prefab-bar" title={prefabRef}>
<span className="pic">
<Package size={13} strokeWidth={1.8} />
@@ -947,7 +995,7 @@ function EditorDetails() {
{visible.map((comp) => (
<ComponentSection
key={comp.name}
- entity={selectedId}
+ entities={ids}
comp={comp}
collapsed={collapsed.has(comp.name)}
onToggle={() => toggle(comp.name)}
@@ -965,10 +1013,10 @@ function EditorDetails() {
y={compMenu.y}
items={[
{
- label: 'Remove Component',
+ label: ids.length > 1 ? `Remove Component (${ids.length})` : 'Remove Component',
danger: true,
icon: <Trash2 size={13} strokeWidth={1.9} />,
- onClick: () => SceneCommands.removeComponent(selectedId, compMenu.comp),
+ onClick: () => fanOut((id) => SceneCommands.removeComponent(id, compMenu.comp)),
},
]}
onClose={() => setCompMenu(null)}
@@ -977,7 +1025,7 @@ function EditorDetails() {
{addOpen && modelEntity && (
<AddComponentMenu
entries={modelAddableComponentEntries(modelEntity)}
- onAdd={(name) => SceneCommands.addComponent(selectedId, name)}
+ onAdd={(name) => fanOut((id) => SceneCommands.addComponent(id, name))}
onClose={() => setAddOpen(false)}
/>
)}
diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.css
index b934a669a..159060350 100644
--- a/desktop/src/theme/inspector.css
+++ b/desktop/src/theme/inspector.css
@@ -120,6 +120,13 @@
.slider .thumb { position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%; background: var(--text); transform: translate(-50%,-50%); box-shadow: var(--shadow-1); }
/* compact exact-entry box paired with a slider track */
.snum { width: 54px; flex-shrink: 0; display: flex; }
+
+/* multi-select: a value the selection disagrees on (shows a "—" placeholder) */
+.prop.mixed .prop-label { color: var(--text-mute); }
+.toggle.mixed { background: var(--srf-5); }
+.toggle.mixed::after { left: 50%; transform: translateX(-50%); background: var(--text-mute); }
+.comp-chk.mixed { background: var(--srf-5); border-color: var(--border-line); color: var(--text-mute); }
+.ent-multi { display: flex; align-items: center; color: var(--text-dim); font-weight: 600; }
.toggle { width: 30px; height: 17px; border-radius: var(--r-pill); background: var(--srf-5); position: relative; cursor: pointer; flex-shrink: 0; transition: background var(--t-fast); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--text-dim); transition: left var(--t-fast) var(--e-out), background var(--t-fast); }
.toggle.on { background: var(--acc); }
diff --git a/desktop/src/types.ts b/desktop/src/types.ts
index 2594b8437..f51bfc0b2 100644
--- a/desktop/src/types.ts
+++ b/desktop/src/types.ts
@@ -79,6 +79,11 @@ export interface InspectorField {
unit?: string;
/** A rarely-edited field — tucked behind the component's "Advanced" fold. */
advanced?: boolean;
+ /**
+ * Multi-selection: the selected entities disagree on this field's value. `value`
+ * holds the primary entity's value (shown muted); an edit fans out to all.
+ */
+ mixed?: boolean;
}
export interface InspectorComponent {
@@ -89,9 +94,10 @@ export interface InspectorComponent {
/**
* The component's enable toggle — its `enabled`/`isActive`/`visible` field +
* current value — surfaced in the header (and hidden from `fields`). Absent for
- * components that can't be disabled (e.g. Transform).
+ * components that can't be disabled (e.g. Transform). `mixed` ⇒ a multi-selection
+ * disagrees (value is the primary's).
*/
- enable?: { key: string; value: boolean };
+ enable?: { key: string; value: boolean; mixed?: boolean };
}
export type AssetType =
diff --git a/desktop/tests/inspector-model.test.ts b/desktop/tests/inspector-model.test.ts
index fe26ea34e..348ab91a3 100644
--- a/desktop/tests/inspector-model.test.ts
+++ b/desktop/tests/inspector-model.test.ts
@@ -276,6 +276,69 @@ describe('Unknown-component inspector (schemas.json consumer)', () => {
});
});
+describe('Multi-selection inspector (D6)', () => {
+ function scene2(): SceneData {
+ return {
+ version: '1.0',
+ name: 'm',
+ entities: [
+ {
+ id: 1,
+ name: 'A',
+ parent: null,
+ children: [],
+ components: [
+ { type: 'Sprite', data: { layer: 0, enabled: true } },
+ { type: 'Camera', data: { isActive: true } },
+ ],
+ },
+ { id: 2, name: 'B', parent: null, children: [], components: [{ type: 'Sprite', data: { layer: 5, enabled: true } }] },
+ ],
+ } as unknown as SceneData;
+ }
+
+ it('shows only the components shared by every selected entity', () => {
+ const S = EditorSession.create();
+ S.model.adopt(scene2(), new Map([[1, 1], [2, 2]]));
+ const comps = S.query.readMultiInspector([1, 2]).map((c) => c.name);
+ expect(comps).toContain('Sprite');
+ expect(comps).not.toContain('Camera'); // only on entity 1
+ });
+
+ it('flags a field the selection disagrees on as mixed (primary value shown)', () => {
+ const S = EditorSession.create();
+ S.model.adopt(scene2(), new Map([[1, 1], [2, 2]]));
+ const sprite = S.query.readMultiInspector([1, 2]).find((c) => c.name === 'Sprite')!;
+ const layer = sprite.fields.find((f) => f.key === 'layer')!;
+ expect(layer.mixed).toBe(true);
+ expect(layer.value).toBe(0); // ids[0] (primary)
+ const color = sprite.fields.find((f) => f.key === 'color');
+ if (color) expect(color.mixed).toBeFalsy(); // both at default → agree
+ });
+
+ it('falls back to the full single-entity inspector for one id', () => {
+ const S = EditorSession.create();
+ S.model.adopt(scene2(), new Map([[1, 1], [2, 2]]));
+ expect(S.query.readMultiInspector([1]).map((c) => c.name)).toContain('Camera');
+ });
+
+ it('marks the enable toggle mixed when the selection disagrees', () => {
+ const S = EditorSession.create();
+ S.model.adopt(
+ {
+ version: '1.0',
+ name: 'm',
+ entities: [
+ { id: 1, name: 'A', parent: null, children: [], components: [{ type: 'Sprite', data: { enabled: true } }] },
+ { id: 2, name: 'B', parent: null, children: [], components: [{ type: 'Sprite', data: { enabled: false } }] },
+ ],
+ } as unknown as SceneData,
+ new Map([[1, 1], [2, 2]]),
+ );
+ expect(S.query.readMultiInspector([1, 2]).find((c) => c.name === 'Sprite')!.enable?.mixed).toBe(true);
+ });
+});
+
describe('Advanced fields (D5)', () => {
it('flags rarely-edited builtin fields as advanced, leaving primaries plain', () => {
const S = EditorSession.create();