add warning when used param is being deleted
"Used" means in graph and connected
This commit is contained in:
@@ -776,6 +776,30 @@ namespace FlaxEditor.Surface
|
||||
private void DeleteParameter(int index)
|
||||
{
|
||||
var window = (IVisjectSurfaceWindow)Values[0];
|
||||
SurfaceParameter param = window.VisjectSurface.Parameters[index];
|
||||
|
||||
int connectedParameterNodeCount = 0;
|
||||
|
||||
List<SurfaceNode> nodes = window.VisjectSurface.Nodes;
|
||||
|
||||
for (int i = 0; i < window.VisjectSurface.Nodes.Count; i++)
|
||||
{
|
||||
if (nodes[i] is IParametersDependantNode node)
|
||||
{
|
||||
if ((Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
|
||||
connectedParameterNodeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
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 caption = "Delete parameter" + singularPlural;
|
||||
|
||||
if (connectedParameterNodeCount > 0)
|
||||
if (MessageBox.Show(msg, caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var action = new AddRemoveParamAction
|
||||
{
|
||||
Window = window,
|
||||
|
||||
Reference in New Issue
Block a user