void FSlomoTrackEditor::HandleAddSlomoTrackMenuEntryExecute() { UMovieScene* MovieScene = GetFocusedMovieScene(); if (MovieScene == nullptr) { return; } UMovieSceneTrack* SlomoTrack = MovieScene->FindMasterTrack<UMovieSceneSlomoTrack>(); if (SlomoTrack != nullptr) { return; } const FScopedTransaction Transaction(NSLOCTEXT("Sequencer", "AddSlomoTrack_Transaction", "Add Play Rate Track")); MovieScene->Modify(); SlomoTrack = FindOrCreateMasterTrack<UMovieSceneSlomoTrack>().Track; ensure(SlomoTrack); UMovieSceneSection* NewSection = SlomoTrack->CreateNewSection(); ensure(NewSection); SlomoTrack->AddSection(*NewSection); GetSequencer()->NotifyMovieSceneDataChanged(); }
FGuid FSequencer::GetHandleToObject( UObject* Object ) { TSharedRef<FMovieSceneInstance> FocusedMovieSceneInstance = GetFocusedMovieSceneInstance(); UMovieScene* FocusedMovieScene = FocusedMovieSceneInstance->GetMovieScene(); FGuid ObjectGuid = ObjectBindingManager->FindGuidForObject( *FocusedMovieScene, *Object ); if (ObjectGuid.IsValid()) { // Make sure that the possessable is still valid, if it's not remove the binding so new one // can be created. This can happen due to undo. FMovieScenePossessable* Possessable = FocusedMovieScene->FindPossessable(ObjectGuid); if (Possessable == nullptr ) { ObjectBindingManager->UnbindPossessableObjects(ObjectGuid); ObjectGuid.Invalidate(); } } bool bPossessableAdded = false; // If the object guid was not found attempt to add it // Note: Only possessed actors can be added like this if( !ObjectGuid.IsValid() && ObjectBindingManager->CanPossessObject( *Object ) ) { // @todo sequencer: Undo doesn't seem to be working at all const FScopedTransaction Transaction( LOCTEXT("UndoPossessingObject", "Possess Object with MovieScene") ); // Possess the object! { // Create a new possessable FocusedMovieScene->Modify(); ObjectGuid = FocusedMovieScene->AddPossessable( Object->GetName(), Object->GetClass() ); if ( IsShotFilteringOn() ) { AddUnfilterableObject(ObjectGuid); } ObjectBindingManager->BindPossessableObject( ObjectGuid, *Object ); bPossessableAdded = true; } } if( bPossessableAdded ) { SpawnOrDestroyPuppetObjects( GetFocusedMovieSceneInstance() ); NotifyMovieSceneDataChanged(); } return ObjectGuid; }
UMovieSceneCameraCutTrack* FCameraCutTrackEditor::FindOrCreateCameraCutTrack() { UMovieScene* FocusedMovieScene = GetFocusedMovieScene(); UMovieSceneTrack* CameraCutTrack = FocusedMovieScene->GetCameraCutTrack(); if (CameraCutTrack == nullptr) { const FScopedTransaction Transaction(LOCTEXT("AddCameraCutTrack_Transaction", "Add Camera Cut Track")); FocusedMovieScene->Modify(); CameraCutTrack = FocusedMovieScene->AddCameraCutTrack(UMovieSceneCameraCutTrack::StaticClass()); } return CastChecked<UMovieSceneCameraCutTrack>(CameraCutTrack); }
void FSequencer::OnActorsDropped( const TArray<TWeakObjectPtr<AActor> >& Actors ) { bool bPossessableAdded = false; for( TWeakObjectPtr<AActor> WeakActor : Actors ) { AActor* Actor = WeakActor.Get(); if( Actor != NULL ) { // Grab the MovieScene that is currently focused. We'll add our Blueprint as an inner of the // MovieScene asset. UMovieScene* OwnerMovieScene = GetFocusedMovieScene(); // @todo sequencer: Undo doesn't seem to be working at all const FScopedTransaction Transaction( LOCTEXT("UndoPossessingObject", "Possess Object with MovieScene") ); // Possess the object! { // Create a new possessable OwnerMovieScene->Modify(); const FGuid PossessableGuid = OwnerMovieScene->AddPossessable( Actor->GetActorLabel(), Actor->GetClass() ); if ( IsShotFilteringOn() ) { AddUnfilterableObject(PossessableGuid); } ObjectBindingManager->BindPossessableObject( PossessableGuid, *Actor ); bPossessableAdded = true; } } } if( bPossessableAdded ) { SpawnOrDestroyPuppetObjects( GetFocusedMovieSceneInstance() ); NotifyMovieSceneDataChanged(); } }
void FSequencer::AddSubMovieScene( UMovieScene* SubMovieScene ) { // @todo Sequencer - sub-moviescenes This should be moved to the sub-moviescene editor SubMovieScene->SetFlags( RF_Transactional ); // Grab the MovieScene that is currently focused. THis is the movie scene that will contain the sub-moviescene UMovieScene* OwnerMovieScene = GetFocusedMovieScene(); // @todo sequencer: Undo doesn't seem to be working at all const FScopedTransaction Transaction( LOCTEXT("UndoAddingObject", "Add Object to MovieScene") ); OwnerMovieScene->Modify(); UMovieSceneTrack* Type = OwnerMovieScene->FindMasterTrack( USubMovieSceneTrack::StaticClass() ) ; if( !Type ) { Type = OwnerMovieScene->AddMasterTrack( USubMovieSceneTrack::StaticClass() ); } USubMovieSceneTrack* SubMovieSceneType = CastChecked<USubMovieSceneTrack>( Type ); SubMovieSceneType->AddMovieSceneSection( SubMovieScene, ScrubPosition ); }
void FSequencerFolderNode::Drop( const TArray<TSharedRef<FSequencerDisplayNode>>& DraggedNodes, EItemDropZone ItemDropZone ) { const FScopedTransaction Transaction( NSLOCTEXT( "SequencerFolderNode", "MoveIntoFolder", "Move items into folder." ) ); GetFolder().SetFlags(RF_Transactional); GetFolder().Modify(); for ( TSharedRef<FSequencerDisplayNode> DraggedNode : DraggedNodes ) { TSharedPtr<FSequencerDisplayNode> ParentSeqNode = DraggedNode->GetParent(); switch ( DraggedNode->GetType() ) { case ESequencerNode::Folder: { TSharedRef<FSequencerFolderNode> DraggedFolderNode = StaticCastSharedRef<FSequencerFolderNode>( DraggedNode ); UMovieScene* FocusedMovieScene = GetParentTree().GetSequencer().GetFocusedMovieSceneSequence()->GetMovieScene(); if ( ItemDropZone == EItemDropZone::OntoItem ) { GetFolder().AddChildFolder( &DraggedFolderNode->GetFolder() ); } else { FocusedMovieScene->Modify(); FocusedMovieScene->GetRootFolders().Add( &DraggedFolderNode->GetFolder() ); } if ( ParentSeqNode.IsValid() ) { checkf( ParentSeqNode->GetType() == ESequencerNode::Folder, TEXT( "Can not remove from unsupported parent node." ) ); TSharedPtr<FSequencerFolderNode> ParentFolder = StaticCastSharedPtr<FSequencerFolderNode>( ParentSeqNode ); ParentFolder->GetFolder().Modify(); ParentFolder->GetFolder().RemoveChildFolder( &DraggedFolderNode->GetFolder() ); } else { FocusedMovieScene->Modify(); FocusedMovieScene->GetRootFolders().Remove( &DraggedFolderNode->GetFolder() ); } break; } case ESequencerNode::Track: { TSharedRef<FSequencerTrackNode> DraggedTrackNode = StaticCastSharedRef<FSequencerTrackNode>( DraggedNode ); if( ItemDropZone == EItemDropZone::OntoItem ) { GetFolder().AddChildMasterTrack( DraggedTrackNode->GetTrack() ); } if ( ParentSeqNode.IsValid() ) { checkf( ParentSeqNode->GetType() == ESequencerNode::Folder, TEXT( "Can not remove from unsupported parent node." ) ); TSharedPtr<FSequencerFolderNode> ParentFolder = StaticCastSharedPtr<FSequencerFolderNode>( ParentSeqNode ); ParentFolder->GetFolder().Modify(); ParentFolder->GetFolder().RemoveChildMasterTrack( DraggedTrackNode->GetTrack() ); } break; } case ESequencerNode::Object: { TSharedRef<FSequencerObjectBindingNode> DraggedObjectBindingNode = StaticCastSharedRef<FSequencerObjectBindingNode>( DraggedNode ); if ( ItemDropZone == EItemDropZone::OntoItem ) { GetFolder().AddChildObjectBinding( DraggedObjectBindingNode->GetObjectBinding() ); } if ( ParentSeqNode.IsValid() ) { checkf( ParentSeqNode->GetType() == ESequencerNode::Folder, TEXT( "Can not remove from unsupported parent node." ) ); TSharedPtr<FSequencerFolderNode> ParentFolder = StaticCastSharedPtr<FSequencerFolderNode>( ParentSeqNode ); ParentFolder->GetFolder().Modify(); ParentFolder->GetFolder().RemoveChildObjectBinding( DraggedObjectBindingNode->GetObjectBinding() ); } break; } } } SetExpansionState( true ); ParentTree.GetSequencer().NotifyMovieSceneDataChanged( EMovieSceneDataChangeType::MovieSceneStructureItemsChanged ); }