Fix Convert to Parameter to check if can perform action

This commit is contained in:
Wojtek Figat
2024-05-20 22:39:46 +02:00
parent c486577b07
commit 5ca61d8568
2 changed files with 4 additions and 4 deletions

View File

@@ -338,7 +338,7 @@ namespace FlaxEditor.CustomEditors.Editors
protected abstract ulong GetValue(object value);
/// <summary>
/// Gets the value from long.
/// Sets the value from long.
/// </summary>
/// <param name="value">The value from editor.</param>
/// <returns>The value to object.</returns>

View File

@@ -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);
}
}