diff --git a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs
index f76faa794..71601ed23 100644
--- a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs
@@ -885,6 +885,17 @@ namespace FlaxEditor.Surface.Archetypes
_selectedAnimation.SelectedIndex = 0;
}
+ ///
+ public override void SetValuesPaste(object[] values)
+ {
+ // Fix Guids pasted as string
+ // TODO: let copy/paste system in Visject handle value types to be strongly typed
+ for (int i = 5; i < values.Length; i += 2)
+ values[i] = Guid.Parse((string)values[i]);
+
+ base.SetValuesPaste(values);
+ }
+
///
public override void OnValuesChanged()
{
diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs
index c5c011db0..da64fe613 100644
--- a/Source/Editor/Surface/SurfaceNode.cs
+++ b/Source/Editor/Surface/SurfaceNode.cs
@@ -1001,6 +1001,15 @@ namespace FlaxEditor.Surface
_isDuringValuesEditing = value;
}
+ ///
+ /// Sets teh node values from the given pasted source. Can be overriden to perform validation or custom values processing.
+ ///
+ /// The input values array.
+ public virtual void SetValuesPaste(object[] values)
+ {
+ Values = values;
+ }
+
///
/// Called when node values set gets changed.
///
diff --git a/Source/Editor/Surface/VisjectSurface.CopyPaste.cs b/Source/Editor/Surface/VisjectSurface.CopyPaste.cs
index 94d41a624..71004aede 100644
--- a/Source/Editor/Surface/VisjectSurface.CopyPaste.cs
+++ b/Source/Editor/Surface/VisjectSurface.CopyPaste.cs
@@ -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);