Merge branch 'anim-fix' of https://github.com/Tryibion/FlaxEngine into Tryibion-anim-fix

This commit is contained in:
Wojtek Figat
2023-10-12 12:12:01 +02:00
2 changed files with 22 additions and 10 deletions

View File

@@ -59,8 +59,11 @@ namespace FlaxEditor.Surface.Archetypes
if (Surface != null) if (Surface != null)
{ {
_assetSelect = GetChild<AssetSelect>(); _assetSelect = GetChild<AssetSelect>();
_assetBox = GetBox(8); if (TryGetBox(8, out var box))
_assetSelect.Visible = !_assetBox.HasAnyConnection; {
_assetBox = box;
_assetSelect.Visible = !_assetBox.HasAnyConnection;
}
UpdateTitle(); UpdateTitle();
} }
} }
@@ -68,7 +71,11 @@ namespace FlaxEditor.Surface.Archetypes
private void UpdateTitle() private void UpdateTitle()
{ {
var asset = Editor.Instance.ContentDatabase.Find((Guid)Values[0]); 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; var style = Style.Current;
Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160); Resize(Mathf.Max(230, style.FontLarge.MeasureText(Title).X + 30), 160);
} }
@@ -78,6 +85,8 @@ namespace FlaxEditor.Surface.Archetypes
{ {
base.ConnectionTick(box); base.ConnectionTick(box);
if (_assetBox == null)
return;
if (box.ID != _assetBox.ID) if (box.ID != _assetBox.ID)
return; return;

View File

@@ -764,14 +764,17 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu
const float startTimePos = (float)tryGetValue(node->GetBox(7), node->Values[3]); const float startTimePos = (float)tryGetValue(node->GetBox(7), node->Values[3]);
// Override animation when animation reference box is connected // Override animation when animation reference box is connected
auto animationAssetBox = node->GetBox(8); auto animationAssetBox = node->TryGetBox(8);
if (animationAssetBox->HasConnection()) if (animationAssetBox)
{ {
const Value assetBoxValue = tryGetValue(animationAssetBox, Value::Null); if (animationAssetBox->HasConnection())
if (assetBoxValue != Value::Null) {
anim = (Animation*)assetBoxValue.AsAsset; const Value assetBoxValue = tryGetValue(animationAssetBox, Value::Null);
else if (assetBoxValue != Value::Null)
anim = nullptr; anim = (Animation*)assetBoxValue.AsAsset;
else
anim = nullptr;
}
} }
const float length = anim ? anim->GetLength() : 0.0f; const float length = anim ? anim->GetLength() : 0.0f;