From 76b84cca4e2b972c3594c2582a47e8f9c0f9853b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 12 Dec 2024 10:40:08 -0600 Subject: [PATCH] Scroll to script on add. --- Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs | 7 +++++++ Source/Editor/Options/InterfaceOptions.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs index e71f9a8bc..583241915 100644 --- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs @@ -424,6 +424,13 @@ namespace FlaxEditor.CustomEditors.Dedicated { presenter.Undo.AddAction(multiAction); presenter.Control.Focus(); + + // Scroll to bottom of script control where a new script is added. + if (presenter.Panel.Parent is Panel p && Editor.Instance.Options.Options.Interface.ScrollToScriptOnAdd) + { + var loc = ScriptsEditor.Layout.Control.BottomLeft; + p.ScrollViewTo(loc); + } } } } diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 1654df920..4cd76adc6 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -258,6 +258,13 @@ namespace FlaxEditor.Options private TextAlignment _tooltipTextAlignment = TextAlignment.Center; + /// + /// Whether to scroll to the script when a script is added to an actor. + /// + [DefaultValue(true)] + [EditorDisplay("Interface"), EditorOrder(322)] + public bool ScrollToScriptOnAdd { get; set; } = true; + /// /// Gets or sets the timestamps prefix mode for output log messages. ///