Simplify sound emitter selection and add play/stop sound buttons

This commit is contained in:
2026-04-02 19:42:22 +02:00
parent fc3e52a957
commit 5bbdae01b4

View File

@@ -1858,14 +1858,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
const targetSoundEmitter =
(link.action.type === "playSound" || link.action.type === "stopSound"
? editorState.document.entities[link.action.targetSoundEmitterId]
: undefined) ?? soundEmitterOptions.find(({ entity }) => {
if (entity.audioAssetId === null) {
return false;
}
const asset = editorState.document.assets[entity.audioAssetId];
return asset?.kind === "audio";
})?.entity;
: undefined) ?? playableSoundEmitterOptions[0]?.entity;
if (targetSoundEmitter === undefined || targetSoundEmitter.kind !== "soundEmitter") {
setStatusMessage("Author a Sound Emitter with an audio asset before switching this link to sound playback.");
@@ -2374,6 +2367,24 @@ export function App({ store, initialStatusMessage }: AppProps) {
>
Add Stop Anim Link
</button>
<button
className="toolbar__button"
type="button"
data-testid={addPlaySoundTestId}
disabled={playableSoundEmitterOptions.length === 0}
onClick={() => handleAddSoundInteractionLink("playSound")}
>
Add Play Sound Link
</button>
<button
className="toolbar__button"
type="button"
data-testid={addStopSoundTestId}
disabled={playableSoundEmitterOptions.length === 0}
onClick={() => handleAddSoundInteractionLink("stopSound")}
>
Add Stop Sound Link
</button>
</div>
</div>
);