bool FUMGSequencerObjectBindingManager::TryGetObjectBindingDisplayName(const TSharedRef<FMovieSceneInstance>& MovieSceneInstance, const FGuid& ObjectGuid, FText& DisplayName) const { // TODO: This gets called every frame for every bound object and could be a potential performance issue for a really complicated animation. TArray<TWeakObjectPtr<UObject>> BindingObjects; GuidToPreviewObjectsMap.MultiFind(ObjectGuid, BindingObjects); TArray<TWeakObjectPtr<UObject>> SlotContentBindingObjects; GuidToSlotContentPreviewObjectsMap.MultiFind(ObjectGuid, SlotContentBindingObjects); if (BindingObjects.Num() == 0 && SlotContentBindingObjects.Num() == 0) { DisplayName = LOCTEXT("NoBoundObjects", "No bound objects"); } else if (BindingObjects.Num() + SlotContentBindingObjects.Num() > 1) { DisplayName = LOCTEXT("Multiple bound objects", "Multilple bound objects"); } else if (BindingObjects.Num() == 1) { DisplayName = FText::FromString(BindingObjects[0].Get()->GetName()); } else // SlotContentBindingObjects.Num() == 1 { UWidget* SlotContent = Cast<UWidget>(SlotContentBindingObjects[0].Get()); FText PanelName = SlotContent->Slot != nullptr && SlotContent->Slot->Parent != nullptr ? FText::FromString(SlotContent->Slot->Parent->GetName()) : LOCTEXT("InvalidPanel", "Invalid Panel"); FText ContentName = FText::FromString(SlotContent->GetName()); DisplayName = FText::Format(LOCTEXT("SlotObject", "{0} ({1} Slot)"), ContentName, PanelName); } return true; }
void GetBindableObjects(UWidget* RootWidget, TArray<FObjectAndDisplayName>& BindableObjects) { TArray<UWidget*> ToTraverse; ToTraverse.Add(RootWidget); while (ToTraverse.Num() > 0) { UWidget* Widget = ToTraverse[0]; ToTraverse.RemoveAt(0); BindableObjects.Add(FObjectAndDisplayName(FText::FromString(Widget->GetName()), Widget)); UUserWidget* UserWidget = Cast<UUserWidget>(Widget); if (UserWidget != nullptr) { TArray<FName> SlotNames; UserWidget->GetSlotNames(SlotNames); for (FName SlotName : SlotNames) { UWidget* Content = UserWidget->GetContentForSlot(SlotName); if (Content != nullptr) { ToTraverse.Add(Content); } } } UPanelWidget* PanelWidget = Cast<UPanelWidget>(Widget); if (PanelWidget != nullptr) { for (UPanelSlot* Slot : PanelWidget->GetSlots()) { if (Slot->Content != nullptr) { FText SlotDisplayName = FText::Format(LOCTEXT("AddMenuSlotFormat", "{0} ({1} Slot)"), FText::FromString(Slot->Content->GetName()), FText::FromString(PanelWidget->GetName())); BindableObjects.Add(FObjectAndDisplayName(SlotDisplayName, Slot)); ToTraverse.Add(Slot->Content); } } } } }