Add IFunctionDependantNode for Visject nodes
This commit is contained in:
@@ -1387,6 +1387,9 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cached signature. This might not be loaded if called from other not initialization (eg. node initialized before this function node). Then use GetSignature method.
|
||||
/// </summary>
|
||||
internal Signature _signature;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1395,6 +1398,13 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
}
|
||||
|
||||
public void GetSignature(out Signature signature)
|
||||
{
|
||||
if (_signature.Node == null)
|
||||
LoadSignature();
|
||||
signature = _signature;
|
||||
}
|
||||
|
||||
private void SaveSignature()
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
@@ -1568,6 +1578,13 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Update node interface
|
||||
UpdateUI();
|
||||
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
{
|
||||
if (Surface.Nodes[i] is IFunctionsDependantNode node)
|
||||
node.OnFunctionEdited(this);
|
||||
}
|
||||
};
|
||||
editor.Show(this, Vector2.Zero);
|
||||
}
|
||||
@@ -1622,6 +1639,13 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
base.OnLoaded();
|
||||
|
||||
LoadSignature();
|
||||
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
{
|
||||
if (Surface.Nodes[i] is IFunctionsDependantNode node)
|
||||
node.OnFunctionCreated(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1639,6 +1663,26 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
// Start editing
|
||||
OnEditSignature();
|
||||
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
{
|
||||
if (Surface.Nodes[i] is IFunctionsDependantNode node)
|
||||
node.OnFunctionCreated(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnDeleted()
|
||||
{
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
{
|
||||
if (Surface.Nodes[i] is IFunctionsDependantNode node)
|
||||
node.OnFunctionDeleted(this);
|
||||
}
|
||||
|
||||
base.OnDeleted();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1647,6 +1691,13 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
base.OnValuesChanged();
|
||||
|
||||
LoadSignature();
|
||||
|
||||
// Send event
|
||||
for (int i = 0; i < Surface.Nodes.Count; i++)
|
||||
{
|
||||
if (Surface.Nodes[i] is IFunctionsDependantNode node)
|
||||
node.OnFunctionEdited(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1752,7 +1803,6 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
{
|
||||
private bool _isTypesChangedEventRegistered;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SetFieldNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
|
||||
: base(id, context, nodeArch, groupArch)
|
||||
{
|
||||
|
||||
31
Source/Editor/Surface/IFunctionDependantNode.cs
Normal file
31
Source/Editor/Surface/IFunctionDependantNode.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEngine;
|
||||
|
||||
namespace FlaxEditor.Surface
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for surface nodes that depend on surface function nodes collection.
|
||||
/// </summary>
|
||||
[HideInEditor]
|
||||
public interface IFunctionsDependantNode
|
||||
{
|
||||
/// <summary>
|
||||
/// On function created.
|
||||
/// </summary>
|
||||
/// <param name="node">The function node.</param>
|
||||
void OnFunctionCreated(SurfaceNode node);
|
||||
|
||||
/// <summary>
|
||||
/// On function signature changed (new name or parameters change).
|
||||
/// </summary>
|
||||
/// <param name="node">The function node.</param>
|
||||
void OnFunctionEdited(SurfaceNode node);
|
||||
|
||||
/// <summary>
|
||||
/// On function removed.
|
||||
/// </summary>
|
||||
/// <param name="node">The function node.</param>
|
||||
void OnFunctionDeleted(SurfaceNode node);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user