From 5ca61d85688b56975b6809468f0a712976b8a461 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 20 May 2024 22:39:46 +0200 Subject: [PATCH] Fix `Convert to Parameter` to check if can perform action --- Source/Editor/CustomEditors/Editors/IntegerEditor.cs | 2 +- Source/Editor/Surface/Archetypes/Constants.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/IntegerEditor.cs b/Source/Editor/CustomEditors/Editors/IntegerEditor.cs index 651310349..3cadedc3c 100644 --- a/Source/Editor/CustomEditors/Editors/IntegerEditor.cs +++ b/Source/Editor/CustomEditors/Editors/IntegerEditor.cs @@ -338,7 +338,7 @@ namespace FlaxEditor.CustomEditors.Editors protected abstract ulong GetValue(object value); /// - /// Gets the value from long. + /// Sets the value from long. /// /// The value from editor. /// The value to object. diff --git a/Source/Editor/Surface/Archetypes/Constants.cs b/Source/Editor/Surface/Archetypes/Constants.cs index 4591459f1..b94bc34cb 100644 --- a/Source/Editor/Surface/Archetypes/Constants.cs +++ b/Source/Editor/Surface/Archetypes/Constants.cs @@ -47,7 +47,8 @@ namespace FlaxEditor.Surface.Archetypes base.OnShowSecondaryContextMenu(menu, location); menu.AddSeparator(); - menu.AddButton("Convert to Parameter", OnConvertToParameter); + var b = menu.AddButton("Convert to Parameter", OnConvertToParameter); + b.Enabled = Surface.Owner is IVisjectSurfaceWindow window && Surface.Owner.SurfaceAsset && window.NewParameterTypes.Contains(_type); } private void OnConvertToParameter() @@ -122,8 +123,7 @@ namespace FlaxEditor.Surface.Archetypes private bool OnParameterRenameValidate(string value) { - if (Surface.Owner is not IVisjectSurfaceWindow window) - throw new Exception("Surface owner is not a Visject Surface Window"); + var window = (IVisjectSurfaceWindow)Surface.Owner; return !string.IsNullOrWhiteSpace(value) && window.VisjectSurface.Parameters.All(x => x.Name != value); } }