diff --git a/Source/Editor/Surface/Archetypes/Parameters.cs b/Source/Editor/Surface/Archetypes/Parameters.cs
index 4509ce753..b6b80e222 100644
--- a/Source/Editor/Surface/Archetypes/Parameters.cs
+++ b/Source/Editor/Surface/Archetypes/Parameters.cs
@@ -13,7 +13,6 @@ using FlaxEditor.Scripting;
using FlaxEditor.Surface.Elements;
using FlaxEngine;
using FlaxEngine.Utilities;
-using System.Linq;
namespace FlaxEditor.Surface.Archetypes
{
@@ -427,7 +426,7 @@ namespace FlaxEditor.Surface.Archetypes
}
///
- public bool IsParamreferenced(SurfaceParameter param)
+ public bool IsParamUsed(SurfaceParameter param)
{
return (Guid)Values[0] == param.ID;
}
@@ -950,7 +949,7 @@ namespace FlaxEditor.Surface.Archetypes
}
///
- public bool IsParamreferenced(SurfaceParameter param)
+ public bool IsParamUsed(SurfaceParameter param)
{
return (Guid)Values[0] == param.ID;
}
diff --git a/Source/Editor/Surface/IParametersDependantNode.cs b/Source/Editor/Surface/IParametersDependantNode.cs
index 0148682f1..4b9507032 100644
--- a/Source/Editor/Surface/IParametersDependantNode.cs
+++ b/Source/Editor/Surface/IParametersDependantNode.cs
@@ -39,6 +39,6 @@ namespace FlaxEditor.Surface
///
/// The parameter.
/// If the parameter is referenced.
- bool IsParamreferenced(SurfaceParameter param);
+ bool IsParamUsed(SurfaceParameter param);
}
}
diff --git a/Source/Editor/Surface/VisjectSurface.Parameters.cs b/Source/Editor/Surface/VisjectSurface.Parameters.cs
index d6cf6ca0b..b31404ec5 100644
--- a/Source/Editor/Surface/VisjectSurface.Parameters.cs
+++ b/Source/Editor/Surface/VisjectSurface.Parameters.cs
@@ -84,5 +84,16 @@ namespace FlaxEditor.Surface
}
MarkAsEdited();
}
+
+ ///
+ public bool IsParamUsed(SurfaceParameter param)
+ {
+ for (int i = 0; i < Nodes.Count; i++)
+ {
+ if (Nodes[i] is IParametersDependantNode node && node.IsParamUsed(param))
+ return true;
+ }
+ return false;
+ }
}
}
diff --git a/Source/Editor/Surface/VisjectSurfaceWindow.cs b/Source/Editor/Surface/VisjectSurfaceWindow.cs
index 5d6a050a6..6d7633b73 100644
--- a/Source/Editor/Surface/VisjectSurfaceWindow.cs
+++ b/Source/Editor/Surface/VisjectSurfaceWindow.cs
@@ -775,32 +775,14 @@ 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];
- int connectedParameterNodeCount = 0;
-
- List nodes = window.VisjectSurface.Nodes;
-
- for (int i = 0; i < window.VisjectSurface.Nodes.Count; i++)
+ if (Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter && window.VisjectSurface.IsParamUsed(param))
{
- if (nodes[i] is IParametersDependantNode node)
- {
- if (displayWarning && node.IsParamreferenced(param))
- connectedParameterNodeCount++;
- }
- }
-
- 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.";
-
- if (connectedParameterNodeCount > 0)
- if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
- return;
+ string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph.\n\nYou can disable this warning in the editor settings.";
+ if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
+ return;
}
var action = new AddRemoveParamAction