From 8eb9df9a18b928b197ec1cc77617a90f64a65c5f Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 11 Oct 2023 15:57:02 -0500 Subject: [PATCH 1/2] Change new anim port to TryGetBox. --- Source/Editor/Surface/Archetypes/Animation.cs | 20 ++++++++++++++----- .../Animations/Graph/AnimGroup.Animation.cpp | 17 +++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs index a05ede1e7..5743b2a84 100644 --- a/Source/Editor/Surface/Archetypes/Animation.cs +++ b/Source/Editor/Surface/Archetypes/Animation.cs @@ -59,8 +59,11 @@ namespace FlaxEditor.Surface.Archetypes if (Surface != null) { _assetSelect = GetChild(); - _assetBox = GetBox(8); - _assetSelect.Visible = !_assetBox.HasAnyConnection; + if (TryGetBox(8, out var box)) + { + _assetBox = box; + _assetSelect.Visible = !_assetBox.HasAnyConnection; + } UpdateTitle(); } } @@ -68,7 +71,11 @@ namespace FlaxEditor.Surface.Archetypes private void UpdateTitle() { var asset = Editor.Instance.ContentDatabase.Find((Guid)Values[0]); - Title = _assetBox.HasAnyConnection || asset == null ? "Animation" : asset.ShortName; + if (_assetBox != null) + Title = _assetBox.HasAnyConnection || asset == null ? "Animation" : asset.ShortName; + else + Title = asset?.ShortName ?? "Animation"; + var style = Style.Current; Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160); } @@ -78,8 +85,11 @@ namespace FlaxEditor.Surface.Archetypes { base.ConnectionTick(box); - if (box.ID != _assetBox.ID) - return; + if (_assetBox != null) + { + if (box.ID != _assetBox.ID) + return; + } _assetSelect.Visible = !box.HasAnyConnection; UpdateTitle(); diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index a19b84370..6e4783d2c 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -764,14 +764,17 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu 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()) + auto animationAssetBox = node->TryGetBox(8); + if (animationAssetBox) { - const Value assetBoxValue = tryGetValue(animationAssetBox, Value::Null); - if (assetBoxValue != Value::Null) - anim = (Animation*)assetBoxValue.AsAsset; - else - anim = nullptr; + 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; From 28d6fe84efde592e384579c27059bca3d5b20f45 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 11 Oct 2023 16:17:59 -0500 Subject: [PATCH 2/2] Small change --- Source/Editor/Surface/Archetypes/Animation.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs index 5743b2a84..40a3d2a63 100644 --- a/Source/Editor/Surface/Archetypes/Animation.cs +++ b/Source/Editor/Surface/Archetypes/Animation.cs @@ -85,11 +85,10 @@ namespace FlaxEditor.Surface.Archetypes { base.ConnectionTick(box); - if (_assetBox != null) - { - if (box.ID != _assetBox.ID) - return; - } + if (_assetBox == null) + return; + if (box.ID != _assetBox.ID) + return; _assetSelect.Visible = !box.HasAnyConnection; UpdateTitle();