Fix pasting or duplicating Multi Blend nodes

This commit is contained in:
Wojtek Figat
2024-10-29 23:08:50 +01:00
parent 0c645e8b0c
commit 2288684950
3 changed files with 36 additions and 4 deletions

View File

@@ -286,13 +286,14 @@ namespace FlaxEditor.Surface
// Initialize
if (nodeData.Values != null && node.Values.Length > 0)
{
if (node.Values != null && node.Values.Length == nodeData.Values.Length)
var nodeValues = (object[])node.Values?.Clone();
if (nodeValues != null && nodeValues.Length == nodeData.Values.Length)
{
// Copy and fix values (Json deserializes may output them in a different format)
for (int l = 0; l < node.Values.Length; l++)
for (int l = 0; l < nodeData.Values.Length; l++)
{
var src = nodeData.Values[l].Value;
var dst = node.Values[l];
var dst = nodeValues[l];
try
{
@@ -364,13 +365,24 @@ namespace FlaxEditor.Surface
Editor.LogWarning(ex);
}
node.Values[l] = src;
nodeValues[l] = src;
}
}
else if (node.Archetype.Flags.HasFlag(NodeFlags.VariableValuesSize))
{
// Copy values
nodeValues = new object[nodeData.Values.Length];
for (int l = 0; l < nodeData.Values.Length; l++)
{
nodeValues[l] = nodeData.Values[l].Value;
}
}
else
{
Editor.LogWarning("Invalid node custom values.");
}
if (nodeValues != null)
node.SetValuesPaste(nodeValues);
}
Context.OnControlLoaded(node, SurfaceNodeActions.Paste);