From a379e9a3b368b02e0a85b749535f9b95a9b818ee Mon Sep 17 00:00:00 2001 From: ycw Date: Sat, 18 May 2024 04:01:07 -0500 Subject: [PATCH] Editor: Fixed script editor title out-of-sync (#28413) * sync script editor title * no dispatching editScript, setValue is enough --- editor/js/Script.js | 20 ++++++++++++++++++++ editor/js/commands/SetScriptValueCommand.js | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/editor/js/Script.js b/editor/js/Script.js index 7d9bd245173f97..59d5db2e9217ee 100644 --- a/editor/js/Script.js +++ b/editor/js/Script.js @@ -429,6 +429,26 @@ function Script( editor ) { } ); + signals.objectChanged.add( function ( object ) { + + if ( object === currentObject ) { + + title.setValue( currentObject.name + ' / ' + currentScript.name ); + + } + + } ); + + signals.scriptChanged.add( function ( script ) { + + if ( script === currentScript ) { + + title.setValue( currentObject.name + ' / ' + currentScript.name ); + + } + + } ); + return container; } diff --git a/editor/js/commands/SetScriptValueCommand.js b/editor/js/commands/SetScriptValueCommand.js index dcf718a32e4ba1..7665e56cc2ceb6 100644 --- a/editor/js/commands/SetScriptValueCommand.js +++ b/editor/js/commands/SetScriptValueCommand.js @@ -31,7 +31,7 @@ class SetScriptValueCommand extends Command { this.script[ this.attributeName ] = this.newValue; - this.editor.signals.scriptChanged.dispatch(); + this.editor.signals.scriptChanged.dispatch( this.script ); } @@ -39,7 +39,7 @@ class SetScriptValueCommand extends Command { this.script[ this.attributeName ] = this.oldValue; - this.editor.signals.scriptChanged.dispatch(); + this.editor.signals.scriptChanged.dispatch( this.script ); }