diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs
index 16b7993de..9bdb88054 100644
--- a/Source/Editor/Surface/Archetypes/Animation.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.cs
@@ -34,6 +34,9 @@ namespace FlaxEditor.Surface.Archetypes
///
public class Sample : SurfaceNode
{
+ private AssetSelect _assetSelect;
+ private Box _assetBox;
+
///
public Sample(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
@@ -54,16 +57,33 @@ namespace FlaxEditor.Surface.Archetypes
base.OnSurfaceLoaded(action);
if (Surface != null)
+ {
+ _assetSelect = GetChild();
+ _assetBox = GetBox(8);
+ _assetSelect.Visible = !_assetBox.HasAnyConnection;
UpdateTitle();
+ }
}
private void UpdateTitle()
{
var asset = Editor.Instance.ContentDatabase.Find((Guid)Values[0]);
- Title = asset?.ShortName ?? "Animation";
+ Title = _assetBox.HasAnyConnection || asset == null ? "Animation" : asset.ShortName;
var style = Style.Current;
Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160);
}
+
+ ///
+ public override void ConnectionTick(Box box)
+ {
+ base.ConnectionTick(box);
+
+ if(box.ID != _assetBox.ID)
+ return;
+
+ _assetSelect.Visible = !box.HasAnyConnection;
+ UpdateTitle();
+ }
}
///
@@ -305,7 +325,8 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Input(0, "Speed", true, typeof(float), 5, 1),
NodeElementArchetype.Factory.Input(1, "Loop", true, typeof(bool), 6, 2),
NodeElementArchetype.Factory.Input(2, "Start Position", true, typeof(float), 7, 3),
- NodeElementArchetype.Factory.Asset(0, Surface.Constants.LayoutOffsetY * 3, 0, typeof(FlaxEngine.Animation)),
+ NodeElementArchetype.Factory.Input(3, "Animation Asset", true, typeof(FlaxEngine.Animation), 8),
+ NodeElementArchetype.Factory.Asset(0, Surface.Constants.LayoutOffsetY * 4, 0, typeof(FlaxEngine.Animation)),
}
},
new NodeArchetype
diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp
index 86b75af86..29288f658 100644
--- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp
+++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp
@@ -750,7 +750,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu
// Animation
case 2:
{
- const auto anim = node->Assets[0].As();
+ auto anim = node->Assets[0].As();
auto& bucket = context.Data->State[node->BucketIndex].Animation;
switch (box->ID)
@@ -762,6 +762,18 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu
const float speed = (float)tryGetValue(node->GetBox(5), node->Values[1]);
const bool loop = (bool)tryGetValue(node->GetBox(6), node->Values[2]);
const float startTimePos = (float)tryGetValue(node->GetBox(7), node->Values[3]);
+
+ // Override animation when animation reference box is connected
+ auto animationAssetBox = node->GetBox(8);
+ if(animationAssetBox->HasConnection())
+ {
+ const Value assetBoxValue = tryGetValue(animationAssetBox, Value::Null);
+ if(assetBoxValue != Value::Null)
+ anim = (Animation*)assetBoxValue.AsAsset;
+ else
+ anim = nullptr;
+ }
+
const float length = anim ? anim->GetLength() : 0.0f;
// Calculate new time position