diff --git a/Source/Editor/CustomEditors/CustomEditorPresenter.cs b/Source/Editor/CustomEditors/CustomEditorPresenter.cs index 927f1d7be..93896107c 100644 --- a/Source/Editor/CustomEditors/CustomEditorPresenter.cs +++ b/Source/Editor/CustomEditors/CustomEditorPresenter.cs @@ -287,7 +287,24 @@ namespace FlaxEditor.CustomEditors } } + /// + /// Gets or sets the value indicating whether properties are read-only. + /// + public bool ReadOnly + { + get => _readOnly; + set + { + if (_readOnly != value) + { + _readOnly = value; + UpdateReadOnly(); + } + } + } + private bool _buildOnUpdate; + private bool _readOnly; /// /// Initializes a new instance of the class. @@ -381,6 +398,8 @@ namespace FlaxEditor.CustomEditors // Restore scroll value if (parentScrollV > -1) panel.VScrollBar.Value = parentScrollV; + if (_readOnly) + UpdateReadOnly(); } /// @@ -391,6 +410,16 @@ namespace FlaxEditor.CustomEditors _buildOnUpdate = true; } + private void UpdateReadOnly() + { + // Only scrollbars are enabled + foreach (var child in Panel.Children) + { + if (!(child is ScrollBar)) + child.Enabled = !_readOnly; + } + } + private void ExpandGroups(LayoutElementsContainer c, bool open) { if (c is Elements.GroupElement group) diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs index 63bde3c8a..584f1c307 100644 --- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs +++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs @@ -1215,11 +1215,7 @@ namespace FlaxEditor.Windows.Assets _canEdit = canEdit; _undo.Enabled = canEdit; _surface.CanEdit = canEdit; - foreach (var child in _propertiesEditor.Panel.Children) - { - if (!(child is ScrollBar)) - child.Enabled = canEdit; - } + _propertiesEditor.ReadOnly = !canEdit; UpdateToolstrip(); }