@@ -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
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsParamreferenced(SurfaceParameter param)
|
||||
public bool IsParamUsed(SurfaceParameter param)
|
||||
{
|
||||
return (Guid)Values[0] == param.ID;
|
||||
}
|
||||
@@ -950,7 +949,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsParamreferenced(SurfaceParameter param)
|
||||
public bool IsParamUsed(SurfaceParameter param)
|
||||
{
|
||||
return (Guid)Values[0] == param.ID;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,6 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
/// <param name="param">The parameter.</param>
|
||||
/// <returns>If the parameter is referenced.</returns>
|
||||
bool IsParamreferenced(SurfaceParameter param);
|
||||
bool IsParamUsed(SurfaceParameter param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,5 +84,16 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
MarkAsEdited();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SurfaceNode> 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
|
||||
|
||||
Reference in New Issue
Block a user