Sequencer: Only add components and properties for selected actors if the given owner is actually selected

This fixes an issue where if you select an actor and then choose +Track component for another actor, they will both get a track. This should only happen if the actor is actually selected.

#jira UE-196636
#rb ludovic.chabant

[CL 28250405 by max chen in ue5-main branch]
This commit is contained in:
max chen
2023-09-26 17:51:17 -04:00
parent 4599cb4911
commit ac09c2531e
2 changed files with 12 additions and 6 deletions
@@ -659,8 +659,9 @@ void FLevelSequenceEditorToolkit::HandleAddComponentActionExecute(UActorComponen
TArray<UActorComponent*> ActorComponents;
ActorComponents.Add(Component);
// Add selected actor components if the given component is from a selected actor
USelection* SelectedActors = GEditor->GetSelectedActors();
if (SelectedActors && SelectedActors->Num() > 0)
if (SelectedActors && SelectedActors->Num() > 0 && SelectedActors->IsSelected(Component->GetOwner()))
{
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter)
{
@@ -788,14 +788,19 @@ void FObjectBindingModel::HandlePropertyMenuItemExecute(FPropertyPath PropertyPa
}
}
for (TViewModelPtr<FObjectBindingModel> ObjectBindingNode : Sequencer->GetViewModel()->GetSelection()->Outliner.Filter<FObjectBindingModel>())
// Only include other selected object bindings if this binding is selected. Otherwise, this will lead to
// confusion with multiple tracks being added to possibly unrelated objects
if (Sequencer->GetViewModel()->GetSelection()->Outliner.IsSelected(SharedThis(this)))
{
FGuid Guid = ObjectBindingNode->GetObjectGuid();
for (auto RuntimeObject : Sequencer->FindBoundObjects(Guid, OwnerModel->GetSequenceID()))
for (TViewModelPtr<FObjectBindingModel> ObjectBindingNode : Sequencer->GetViewModel()->GetSelection()->Outliner.Filter<FObjectBindingModel>())
{
if (Sequencer->CanKeyProperty(FCanKeyPropertyParams(RuntimeObject->GetClass(), PropertyPath)))
FGuid Guid = ObjectBindingNode->GetObjectGuid();
for (auto RuntimeObject : Sequencer->FindBoundObjects(Guid, OwnerModel->GetSequenceID()))
{
KeyableBoundObjects.AddUnique(RuntimeObject.Get());
if (Sequencer->CanKeyProperty(FCanKeyPropertyParams(RuntimeObject->GetClass(), PropertyPath)))
{
KeyableBoundObjects.AddUnique(RuntimeObject.Get());
}
}
}
}