Fix Convert to Parameter to check if can perform action
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user