You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added the abiity to tag and retrieve any anim graph node (similar to how we could reference linked anim graph nodes previously). Ported linked anim graph nodes to use the new system Added the ability to reference any anim graph node by tag (via a new custom node, spawnable from the context menu, with the appearance of an actor reference in a level blueprint) Added tag display and editing in the bottom-right of anim graph nodes Added new override point to SGraphNodeK2Var to allow for title widget parameters to be overriden by child classes #jira UE-126286 - Anim node functions: Add anim node references #rb Jurre.deBaare #ROBOMERGE-AUTHOR: thomas.sarkanen #ROBOMERGE-SOURCE: CL 17472894 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530) [CL 17472913 by thomas sarkanen in ue5-release-engine-test branch]
151 lines
4.1 KiB
C++
151 lines
4.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_LinkedAnimGraph.h"
|
|
|
|
#include "AnimGraphNode_AssetPlayerBase.h"
|
|
#include "AnimGraphNode_CallFunction.h"
|
|
#include "BlueprintNodeSpawner.h"
|
|
#include "Animation/AnimBlueprint.h"
|
|
#include "AssetRegistry/AssetRegistryModule.h"
|
|
#include "Engine/Blueprint.h"
|
|
#include "BlueprintActionDatabaseRegistrar.h"
|
|
#include "IAnimBlueprintCopyTermDefaultsContext.h"
|
|
#include "KismetCompiler.h"
|
|
#include "UObject/UE5MainStreamObjectVersion.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UAnimGraphNode_LinkedAnimGraph"
|
|
|
|
void UAnimGraphNode_LinkedAnimGraph::PostPasteNode()
|
|
{
|
|
// Clear incompatible target class
|
|
if(UClass* InstanceClass = GetTargetClass())
|
|
{
|
|
if(UAnimBlueprint* LinkedBlueprint = Cast<UAnimBlueprint>(UBlueprint::GetBlueprintFromClass(InstanceClass)))
|
|
{
|
|
if(UAnimBlueprint* ThisBlueprint = GetAnimBlueprint())
|
|
{
|
|
if(!LinkedBlueprint->bIsTemplate && !ThisBlueprint->bIsTemplate && LinkedBlueprint->TargetSkeleton != ThisBlueprint->TargetSkeleton)
|
|
{
|
|
Node.InstanceClass = nullptr;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
TArray<UEdGraph*> UAnimGraphNode_LinkedAnimGraph::GetExternalGraphs() const
|
|
{
|
|
if(UClass* InstanceClass = GetTargetClass())
|
|
{
|
|
if(UAnimBlueprint* LinkedBlueprint = Cast<UAnimBlueprint>(UBlueprint::GetBlueprintFromClass(InstanceClass)))
|
|
{
|
|
for(UEdGraph* Graph : LinkedBlueprint->FunctionGraphs)
|
|
{
|
|
if(Graph->GetFName() == UEdGraphSchema_K2::GN_AnimGraph)
|
|
{
|
|
return { Graph };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return TArray<UEdGraph*>();
|
|
}
|
|
|
|
void UAnimGraphNode_LinkedAnimGraph::SetupFromAsset(const FAssetData& InAssetData, bool bInIsTemplateNode)
|
|
{
|
|
if(InAssetData.IsValid())
|
|
{
|
|
InAssetData.GetTagValue("TargetSkeleton", SkeletonName);
|
|
if(SkeletonName == TEXT("None"))
|
|
{
|
|
SkeletonName.Empty();
|
|
}
|
|
|
|
if(!bInIsTemplateNode)
|
|
{
|
|
UAnimBlueprint* AnimBlueprint = CastChecked<UAnimBlueprint>(InAssetData.GetAsset());
|
|
Node.InstanceClass = AnimBlueprint->GeneratedClass.Get();
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_LinkedAnimGraph::GetMenuActions(FBlueprintActionDatabaseRegistrar& InActionRegistrar) const
|
|
{
|
|
UAnimGraphNode_AssetPlayerBase::GetMenuActionsHelper(
|
|
InActionRegistrar,
|
|
GetClass(),
|
|
{ UAnimBlueprint::StaticClass()},
|
|
{ },
|
|
[](const FAssetData& InAssetData, UClass* InClass)
|
|
{
|
|
if(InAssetData.IsValid())
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescFormat", "{0} - Linked Anim Graph"), FText::FromName(InAssetData.AssetName));
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("MenuDesc", "Linked Anim Graph");
|
|
}
|
|
},
|
|
[](const FAssetData& InAssetData, UClass* InClass)
|
|
{
|
|
if(InAssetData.IsValid())
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescTooltipFormat", "Linked Anim Graph\n'{0}'"), FText::FromName(InAssetData.ObjectPath));
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("MenuDescTooltip", "Linked Anim Graph");
|
|
}
|
|
},
|
|
[](UEdGraphNode* InNewNode, bool bInIsTemplateNode, const FAssetData InAssetData)
|
|
{
|
|
UAnimGraphNode_LinkedAnimGraph* GraphNode = CastChecked<UAnimGraphNode_LinkedAnimGraph>(InNewNode);
|
|
GraphNode->SetupFromAsset(InAssetData, bInIsTemplateNode);
|
|
});
|
|
}
|
|
|
|
bool UAnimGraphNode_LinkedAnimGraph::IsActionFilteredOut(class FBlueprintActionFilter const& Filter)
|
|
{
|
|
bool bIsFilteredOut = false;
|
|
|
|
if(!SkeletonName.IsEmpty())
|
|
{
|
|
FBlueprintActionContext const& FilterContext = Filter.Context;
|
|
|
|
for (UBlueprint* Blueprint : FilterContext.Blueprints)
|
|
{
|
|
if (UAnimBlueprint* AnimBlueprint = Cast<UAnimBlueprint>(Blueprint))
|
|
{
|
|
if(AnimBlueprint->TargetSkeleton != nullptr && !AnimBlueprint->TargetSkeleton->IsCompatibleSkeletonByAssetString(SkeletonName))
|
|
{
|
|
bIsFilteredOut = true;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Not an animation Blueprint, cannot use
|
|
bIsFilteredOut = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return bIsFilteredOut;
|
|
}
|
|
|
|
void UAnimGraphNode_LinkedAnimGraph::Serialize(FArchive& Ar)
|
|
{
|
|
Super::Serialize(Ar);
|
|
|
|
Ar.UsingCustomVersion(FUE5MainStreamObjectVersion::GUID);
|
|
|
|
if(Ar.IsLoading() && Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::AnimGraphNodeTaggingAdded)
|
|
{
|
|
// Transfer old tag to new system
|
|
SetTagInternal(Node.Tag_DEPRECATED);
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE |