Why does FSequencer::IsPreview return SilentModeCount != 0?

I was trying to implement some code that checked IMovieScenePlayer->IsPreview today and realized that it was returning false for the FSequencer in a custom tool of mine. I tracked this down to the fact that FSequencer’s override of IsPreview returns `SilentModeCount != 0`. I was under the impression that FSequencer was always for preview and I don’t understand what silent mode has to do with being preview or not. Is this a mistake?

[Attachment Removed]

Hello Ford,

That code looks dead to me. I don’t see anything calling IsPreview(). It should be removed. I seem to recall it having something to do with the camera cut track / cinematic shot track thumbnails - putting Sequencer in a preview mode to render the thumbnails. But that code doesn’t seem to call IsPreview() anymore.

[Attachment Removed]

Perhaps. The original intent of this function wasn’t to determine whether it’s in a editor preview state or not. The function was poorly named.

For now, I would stick with getting the playback context and checking the world type if you need to determine whether it’s an editor preview state or not (just like you pointed out that UMovieSceneReplaceableBindingBase is doing). As for the future, we could potentially revisit this but it won’t be for 5.8 as we’re getting close our internal deadlines for it.

[Attachment Removed]

I agree that it looks dead, but I don’t agree that it should be removed. I think it should simply be fixed to return true for FSequencer. I have a use-case for checking if the sequence player is for preview or not, and I believe it might even be beneficial to change engine code to use this function.

For example take a look at UMovieSceneReplaceableBindingBase - currently the code checks if the context world is EWorldType::Editor to determine if it should spawn its preview spawnable. This does not properly support standalone toolkits using an FSequencer with an EditorPreview world or actors spawned in the world that have their own sequence players that should not be treated like previews even in Editor or EditorPreview worlds. It would be better for this code to test if the player is a preview player. For example, UMovieSceneReplaceableBindingBase::WillSpawnObject could be written like this::

bool UMovieSceneReplaceableBindingBase::WillSpawnObject(TSharedRef<const UE::MovieScene::FSharedPlaybackState> SharedPlaybackState) const
{
#if WITH_EDITOR
    const IMovieScenePlayer* Player = UE::MovieScene::FPlayerIndexPlaybackCapability::GetPlayer(SharedPlaybackState);
    if (Player && Player->IsPreview()))
    {
        return true;
    }
#endif
    return false;
}

[Attachment Removed]