move used checks to interface
This commit is contained in:
@@ -13,6 +13,7 @@ using FlaxEditor.Scripting;
|
||||
using FlaxEditor.Surface.Elements;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.Utilities;
|
||||
using System.Linq;
|
||||
|
||||
namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
@@ -425,6 +426,20 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
UpdateCombo();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface)
|
||||
{
|
||||
for (int i = 0; i < surface.Nodes.Count; i++)
|
||||
{
|
||||
if (surface.Nodes[i] is IParametersDependantNode node)
|
||||
{
|
||||
return (Guid)surface.Nodes[i].Values[0] == param.ID && surface.Nodes[i].GetBoxes().Any(b => b.Connections.Count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
@@ -942,6 +957,20 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
UpdateCombo();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface)
|
||||
{
|
||||
for (int i = 0; i < surface.Nodes.Count; i++)
|
||||
{
|
||||
if (surface.Nodes[i] is IParametersDependantNode node)
|
||||
{
|
||||
return (Guid)surface.Nodes[i].Values[0] == param.ID && surface.Nodes[i].GetBoxes().Any(b => b.Connections.Count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoaded(SurfaceNodeActions action)
|
||||
{
|
||||
|
||||
@@ -33,5 +33,13 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
/// <param name="param">The parameter.</param>
|
||||
void OnParamDeleted(SurfaceParameter param);
|
||||
|
||||
/// <summary>
|
||||
/// Get if the parameter is referenced in a graph. Referenced in this case means in a graph and at least one node in-/output connected to another node.
|
||||
/// </summary>
|
||||
/// <param name="param">The parameter.</param>
|
||||
/// /// <param name="surface">The visject surface.</param>
|
||||
/// <returns>How often the parameter is referenced.</returns>
|
||||
bool IsParameterReferenced(SurfaceParameter param, VisjectSurface surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ namespace FlaxEditor.Surface
|
||||
{
|
||||
if (nodes[i] is IParametersDependantNode node)
|
||||
{
|
||||
if (displayWarning && (Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
|
||||
if (displayWarning && node.IsParameterReferenced(param, window.VisjectSurface))
|
||||
connectedParameterNodeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user