게임 개발/Unreal Engine

[UE] Animation Preview 에디터에서 USkeletalMeshComponent 얻기

지노윈 2023. 1. 16. 22:32
반응형

AnimNofity 혹은 AnimNotifyState에서 "USkeletalMeshComponent* MeshComp"를 파라미터로 넘겨 받는다.

virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override;

virtual void NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference) override;
virtual void NotifyTick(USkeletalMeshComponent * MeshComp, UAnimSequenceBase * Animation, float FrameDeltaTime, const FAnimNotifyEventReference& EventReference) override;
virtual void NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override;

 

다음은 에디터 관련 코드에서도 USkeletalMeshComponent를 얻오는 샘플 코드 입니다.

void UAnimNotifyState_FX::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
#if	WITH_EDITORONLY_DATA
	Super::PostEditChangeProperty(PropertyChangedEvent);

	const FName PropertyName = (PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None);

	const USkeletalMeshComponent* EditorSkeletalMeshComp = nullptr;
	for (TObjectIterator<USkeletalMeshComponent> It; It; ++It)
	{
		const USkeletalMeshComponent* SkeletalComp = *It;
		if (SkeletalComp == nullptr || SkeletalComp->GetOwner() == nullptr)
			continue;

		if (SkeletalComp->GetOwner()->GetName().Contains(TEXT("AnimationEditorPreviewActor")))
		{
			EditorSkeletalMeshComp = SkeletalComp;
		}
	}

	if(EditorSkeletalMeshComp == nullptr)
		return;

	if (PropertyChangedEvent.MemberProperty->GetName().Equals(TEXT("FxTransformDataContainer")))
	{
    	...
	}
    
#endif
}