From 4e5d33e88cd35965bd542e8f39f2af44b257a1ab Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Fri, 17 May 2024 22:15:18 +0800 Subject: [PATCH] vault backup: 2024-05-17 22:15:18 --- .../Sequence/Sequence Runtime Binding.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/03-UnrealEngine/Sequence/Sequence Runtime Binding.md b/03-UnrealEngine/Sequence/Sequence Runtime Binding.md index 260eae6..0382563 100644 --- a/03-UnrealEngine/Sequence/Sequence Runtime Binding.md +++ b/03-UnrealEngine/Sequence/Sequence Runtime Binding.md @@ -6,6 +6,8 @@ tags: rating: ⭐ --- # 前言 +***MovieSceneTextTrack ***引擎插件可以作为参考。 + 参考: 1. [sequencer mute tracks at runtime from c](https://forums.unrealengine.com/t/sequencer-mute-tracks-at-runtime-from-c/476278/3) @@ -154,6 +156,83 @@ TArray FSequencerUtilities::AddActors(TSharedRef Sequencer, c } ``` +其他参考 +```c++ +const FGuid PossessableGuid = OwnerMovieScene->AddPossessable(InName, InObject.GetClass()); + +if (!OwnerMovieScene->FindPossessable(PossessableGuid)->BindSpawnableObject(Sequencer->GetFocusedTemplateID(), &InObject, &Sequencer.Get())) +{ + OwnerSequence->BindPossessableObject(PossessableGuid, InObject, BindingContext); +} +``` + +```c++ +FGuid FSequencerUtilities::CreateBinding(TSharedRef Sequencer, UObject& InObject, const FString& InName) +{ + const FScopedTransaction Transaction(LOCTEXT("CreateBinding", "Create New Binding")); + + UMovieSceneSequence* OwnerSequence = Sequencer->GetFocusedMovieSceneSequence(); + UMovieScene* OwnerMovieScene = OwnerSequence->GetMovieScene(); + + OwnerSequence->Modify(); + OwnerMovieScene->Modify(); + + const FGuid PossessableGuid = OwnerMovieScene->AddPossessable(InName, InObject.GetClass()); + + // Attempt to use the parent as a context if necessary + UObject* ParentObject = OwnerSequence->GetParentObject(&InObject); + UObject* BindingContext = Sequencer->GetPlaybackContext(); + + AActor* ParentActorAdded = nullptr; + FGuid ParentGuid; + + if (ParentObject) + { + // Ensure we have possessed the outer object, if necessary + ParentGuid = Sequencer->GetHandleToObject(ParentObject, false); + if (!ParentGuid.IsValid()) + { + ParentGuid = Sequencer->GetHandleToObject(ParentObject); + ParentActorAdded = Cast(ParentObject); + } + + if (OwnerSequence->AreParentContextsSignificant()) + { + BindingContext = ParentObject; + } + + // Set up parent/child guids for possessables within spawnables + if (ParentGuid.IsValid()) + { + FMovieScenePossessable* ChildPossessable = OwnerMovieScene->FindPossessable(PossessableGuid); + if (ensure(ChildPossessable)) + { + ChildPossessable->SetParent(ParentGuid, OwnerMovieScene); + } + + FMovieSceneSpawnable* ParentSpawnable = OwnerMovieScene->FindSpawnable(ParentGuid); + if (ParentSpawnable) + { + ParentSpawnable->AddChildPossessable(PossessableGuid); + } + } + } + + if (!OwnerMovieScene->FindPossessable(PossessableGuid)->BindSpawnableObject(Sequencer->GetFocusedTemplateID(), &InObject, &Sequencer.Get())) + { + OwnerSequence->BindPossessableObject(PossessableGuid, InObject, BindingContext); + } + + // Broadcast if a parent actor was added as a result of adding this object + if (ParentActorAdded && ParentGuid.IsValid()) + { + Sequencer->OnActorAddedToSequencer().Broadcast(ParentActorAdded, ParentGuid); + } + + return PossessableGuid; +} +``` + ### FAudioTrackEditor FAudioTrackEditor::HandleAssetAdded(UObject* Asset, const FGuid& TargetObjectGuid) => FAudioTrackEditor::AddNewSound() => UMovieSceneAudioTrack::AddNewSoundOnRow(USoundBase* Sound, FFrameNumber Time, int32 RowIndex) @@ -162,6 +241,7 @@ FAudioTrackEditor::HandleAssetAdded(UObject* Asset, const FGuid& TargetObjectGui - UMovieSceneSkeletalAnimationSection - FSkeletalAnimationTrackEditor - UMovieSceneSkeletalAnimationSystem + - 里面有介绍System相关的逻辑 https://zhuanlan.zhihu.com/p/413151867 - FSkeletalAnimationTrackEditMode Track的编辑器注册位于MovieSceneToolsModule.cpp: