diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index d8493a70a..976f47d1b 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -396,6 +396,13 @@ namespace FlaxEditor.Options [EditorDisplay("Visject", "Grid Snapping Size"), EditorOrder(551), Tooltip("Defines the size of the grid for nodes snapping."), VisibleIf(nameof(SurfaceGridSnapping))] public float SurfaceGridSnappingSize { get; set; } = 20.0f; + /// + /// Gets or sets a value that indicates if a warning should be displayed when deleting a Visject parameter that is used in a graph. + /// + [DefaultValue(true)] + [EditorDisplay("Visject", "Warn when deleting used parameter"), EditorOrder(552)] + public bool WarnOnDeletingUsedVisjectParameter { get; set; } = true; + private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal(EditorAssets.PrimaryFont); private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal(EditorAssets.InconsolataRegularFont); diff --git a/Source/Editor/Surface/VisjectSurfaceWindow.cs b/Source/Editor/Surface/VisjectSurfaceWindow.cs index fdb9fa9bc..57ec0d2c9 100644 --- a/Source/Editor/Surface/VisjectSurfaceWindow.cs +++ b/Source/Editor/Surface/VisjectSurfaceWindow.cs @@ -775,6 +775,8 @@ namespace FlaxEditor.Surface private void DeleteParameter(int index) { + bool displayWarning = Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter; + var window = (IVisjectSurfaceWindow)Values[0]; SurfaceParameter param = window.VisjectSurface.Parameters[index]; @@ -786,18 +788,20 @@ namespace FlaxEditor.Surface { if (nodes[i] is IParametersDependantNode node) { - if ((Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0)) + if (displayWarning && (Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0)) connectedParameterNodeCount++; } } - string singularPlural = connectedParameterNodeCount > 1 ? "s" : ""; + if (displayWarning) + { + string singularPlural = connectedParameterNodeCount > 1 ? "s" : ""; + string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings."; - string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings."; - - if (connectedParameterNodeCount > 0) - if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) - return; + if (connectedParameterNodeCount > 0) + if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) + return; + } var action = new AddRemoveParamAction {