@@ -13,7 +13,6 @@ using FlaxEditor.Scripting;
|
|||||||
using FlaxEditor.Surface.Elements;
|
using FlaxEditor.Surface.Elements;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.Utilities;
|
using FlaxEngine.Utilities;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace FlaxEditor.Surface.Archetypes
|
namespace FlaxEditor.Surface.Archetypes
|
||||||
{
|
{
|
||||||
@@ -427,7 +426,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsParamreferenced(SurfaceParameter param)
|
public bool IsParamUsed(SurfaceParameter param)
|
||||||
{
|
{
|
||||||
return (Guid)Values[0] == param.ID;
|
return (Guid)Values[0] == param.ID;
|
||||||
}
|
}
|
||||||
@@ -950,7 +949,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsParamreferenced(SurfaceParameter param)
|
public bool IsParamUsed(SurfaceParameter param)
|
||||||
{
|
{
|
||||||
return (Guid)Values[0] == param.ID;
|
return (Guid)Values[0] == param.ID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="param">The parameter.</param>
|
/// <param name="param">The parameter.</param>
|
||||||
/// <returns>If the parameter is referenced.</returns>
|
/// <returns>If the parameter is referenced.</returns>
|
||||||
bool IsParamreferenced(SurfaceParameter param);
|
bool IsParamUsed(SurfaceParameter param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,5 +84,16 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
MarkAsEdited();
|
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)
|
private void DeleteParameter(int index)
|
||||||
{
|
{
|
||||||
bool displayWarning = Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter;
|
|
||||||
|
|
||||||
var window = (IVisjectSurfaceWindow)Values[0];
|
var window = (IVisjectSurfaceWindow)Values[0];
|
||||||
SurfaceParameter param = window.VisjectSurface.Parameters[index];
|
SurfaceParameter param = window.VisjectSurface.Parameters[index];
|
||||||
|
|
||||||
int connectedParameterNodeCount = 0;
|
if (Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter && window.VisjectSurface.IsParamUsed(param))
|
||||||
|
|
||||||
List<SurfaceNode> nodes = window.VisjectSurface.Nodes;
|
|
||||||
|
|
||||||
for (int i = 0; i < window.VisjectSurface.Nodes.Count; i++)
|
|
||||||
{
|
{
|
||||||
if (nodes[i] is IParametersDependantNode node)
|
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)
|
||||||
if (displayWarning && node.IsParamreferenced(param))
|
return;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var action = new AddRemoveParamAction
|
var action = new AddRemoveParamAction
|
||||||
|
|||||||
Reference in New Issue
Block a user