1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
TMap< FName, FTransformCurve> FAnimTimelineTrack::TracksFTransformCurveContainer;
void FAnimTimelineTrack::CopyAllAdditiveLayerTracks() { TracksFTransformCurveContainer.Empty();
const FScopedTransaction Transaction(LOCTEXT("AnimTracks_CopyAllTracks", "Copy All Tracks"));
UAnimSequenceBase* SequenceBase = GetModel()->GetAnimSequenceBase(); for (auto& Curve : SequenceBase->RawCurveData.TransformCurves) { TracksFTransformCurveContainer.Add(Curve.Name.DisplayName, Curve); } }
void FAnimTimelineTrack::PasteAdditiveLayerTracks() { const FScopedTransaction Transaction(LOCTEXT("AnimTracks_PasteAllTracks", "Paste All Tracks"));
UAnimSequenceBase* AnimSequenceBase = GetModel()->GetAnimSequenceBase(); const UAnimSequence* AnimSequence = Cast<UAnimSequence>(AnimSequenceBase); if(AnimSequence) { UE_LOG(LogAnimation, Display, TEXT("Cast AnimSequence Success")); AnimSequenceBase->Modify(); TArray<FTransformCurve> NewTransformCurvesContainer; TArray<FName> AnimationTrackNames = AnimSequence->GetAnimationTrackNames(); for(auto& T: TracksFTransformCurveContainer) { const FName TrackName = T.Key; for (auto& Name : AnimationTrackNames) { if(Name == TrackName) { UE_LOG(LogAnimation, Display, TEXT("Animation track : %s ."), *TrackName.ToString()); NewTransformCurvesContainer.Add(T.Value); break; } } }
AnimSequenceBase->RawCurveData.TransformCurves.Empty(); AnimSequenceBase->RawCurveData.TransformCurves = NewTransformCurvesContainer; AnimSequenceBase->RefreshCurveData(); GetModel()->RefreshTracks(); } }
TSharedRef<SWidget> FAnimTimelineTrack::BuildCurvesSubMenu() { FMenuBuilder MenuBuilder(true, GetModel()->GetCommandList()); UAnimSequenceBase* AnimSequenceBase = GetModel()->GetAnimSequenceBase(); MenuBuilder.BeginSection("Tracks", LOCTEXT("AdditiveLayerTracksSection", "Tracks")); { if (AnimSequenceBase->RawCurveData.TransformCurves.Num() > 0) { MenuBuilder.AddMenuEntry( LOCTEXT("CopyAllAdditiveLayerTracks", "Copy All Additive Layer Tracks"), LOCTEXT("CopyAllAdditiveLayerTracks_ToolTip", "Copy All Additive Layer Tracks"), FSlateIcon(), FUIAction(FExecuteAction::CreateSP(this, &FAnimTimelineTrack::CopyAllAdditiveLayerTracks)) ); } if (TracksFTransformCurveContainer.Num() > 0) { MenuBuilder.AddMenuEntry( LOCTEXT("PasteAdditiveLayerTracks", "Paste Additive Layer Tracks"), LOCTEXT("PasteAdditiveLayerTracks_ToolTip", "Paste Additive Layer Tracks"), FSlateIcon(), FUIAction(FExecuteAction::CreateSP(this, &FAnimTimelineTrack::PasteAdditiveLayerTracks)) ); } } MenuBuilder.EndSection(); return MenuBuilder.MakeWidget(); }
TSharedRef<SWidget> FAnimTimelineTrack::GenerateContainerWidgetForOutliner(const TSharedRef<SAnimOutlinerItem>& InRow) {
InnerHorizontalBox->AddSlot() .AutoWidth() .HAlign(HAlign_Right) .VAlign(VAlign_Center) .Padding(OutlinerRightPadding, 1.0f) [ PersonaUtils::MakeTrackButton(LOCTEXT("EditTracksButtonText", "Tracks"), FOnGetContent::CreateSP(this, &FAnimTimelineTrack::BuildCurvesSubMenu), MakeAttributeSP(this, &FAnimTimelineTrack::IsHovered)) ]; }
|